From: Christoph Hellwig <hch@infradead.org>
To: xfs@oss.sgi.com
Subject: [PATCH 19/27] xfs: kill struct xfs_dir2_data
Date: Fri, 01 Jul 2011 05:43:40 -0400 [thread overview]
Message-ID: <20110701094606.199361663@bombadil.infradead.org> (raw)
In-Reply-To: 20110701094321.936534538@bombadil.infradead.org
[-- Attachment #1: xfs-kill-xfs_dir2_data_t --]
[-- Type: text/plain, Size: 5902 bytes --]
Remove the confusing xfs_dir2_data structure. It is supposed to describe
an XFS dir2 data btree block, but due to the variable sized nature of
almost all elements in it it can't actuall do anything close to that
job. In addition to accessing the fixed offset header structure it was
only used to get a pointer to the first dir or unused entry after it,
which can be trivially replaced by pointer arithmetics on the header
pointer. For most users that is actually more natural anyway, as they
don't use a typed pointer but rather a character pointer for further
arithmetics.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfs/fs/xfs/xfs_dir2_data.c
===================================================================
--- xfs.orig/fs/xfs/xfs_dir2_data.c 2011-06-30 09:38:40.133400821 +0200
+++ xfs/fs/xfs/xfs_dir2_data.c 2011-06-30 09:38:41.643400800 +0200
@@ -53,7 +53,6 @@ xfs_dir2_data_check(
xfs_dir2_data_free_t *bf; /* bestfree table */
xfs_dir2_block_tail_t *btp=NULL; /* block tail */
int count; /* count of entries found */
- xfs_dir2_data_t *d; /* data block pointer */
xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_data_entry_t *dep; /* data entry */
xfs_dir2_data_free_t *dfp; /* bestfree entry */
@@ -70,10 +69,9 @@ xfs_dir2_data_check(
struct xfs_name name;
mp = dp->i_mount;
- d = bp->data;
- hdr = &d->hdr;
+ hdr = bp->data;
bf = hdr->bestfree;
- p = (char *)d->u;
+ p = (char *)(hdr + 1);
if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) {
btp = xfs_dir2_block_tail_p(mp, hdr);
@@ -336,7 +334,6 @@ xfs_dir2_data_freescan(
xfs_dir2_data_hdr_t *hdr, /* data block header */
int *loghead) /* out: log data header */
{
- xfs_dir2_data_t *d = (xfs_dir2_data_t *)hdr;
xfs_dir2_block_tail_t *btp; /* block tail */
xfs_dir2_data_entry_t *dep; /* active data entry */
xfs_dir2_data_unused_t *dup; /* unused data entry */
@@ -355,7 +352,7 @@ xfs_dir2_data_freescan(
/*
* Set up pointers.
*/
- p = (char *)d->u;
+ p = (char *)(hdr + 1);
if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = xfs_dir2_block_tail_p(mp, hdr);
endp = (char *)xfs_dir2_block_leaf_p(btp);
@@ -398,7 +395,6 @@ xfs_dir2_data_init(
xfs_dabuf_t **bpp) /* output block buffer */
{
xfs_dabuf_t *bp; /* block buffer */
- xfs_dir2_data_t *d; /* pointer to block */
xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_inode_t *dp; /* incore directory inode */
xfs_dir2_data_unused_t *dup; /* unused entry pointer */
@@ -424,8 +420,7 @@ xfs_dir2_data_init(
/*
* Initialize the header.
*/
- d = bp->data;
- hdr = &d->hdr;
+ hdr = bp->data;
hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr));
for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
@@ -436,7 +431,7 @@ xfs_dir2_data_init(
/*
* Set up an unused entry for the block's body.
*/
- dup = &d->u[0].unused;
+ dup = (xfs_dir2_data_unused_t *)(hdr + 1);
dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
t = mp->m_dirblksize - (uint)sizeof(*hdr);
Index: xfs/fs/xfs/xfs_dir2_data.h
===================================================================
--- xfs.orig/fs/xfs/xfs_dir2_data.h 2011-06-30 09:38:40.136734154 +0200
+++ xfs/fs/xfs/xfs_dir2_data.h 2011-06-30 09:38:41.646734133 +0200
@@ -20,6 +20,22 @@
/*
* Directory format 2, data block structures.
+ *
+ * A pure data block looks like the following drawing on disk:
+ *
+ * +-------------------------------------------------+
+ * | xfs_dir2_data_hdr_t |
+ * +-------------------------------------------------+
+ * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
+ * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
+ * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
+ * | ... |
+ * +-------------------------------------------------+
+ * | unused space |
+ * +-------------------------------------------------+
+ *
+ * As all the entries are variable sized structures the accessors in this
+ * file need to be used to iterate over them.
*/
struct xfs_dabuf;
@@ -103,23 +119,6 @@ typedef struct xfs_dir2_data_unused {
__be16 tag; /* starting offset of us */
} xfs_dir2_data_unused_t;
-typedef union {
- xfs_dir2_data_entry_t entry;
- xfs_dir2_data_unused_t unused;
-} xfs_dir2_data_union_t;
-
-/*
- * Generic data block structure, for xfs_db.
- */
-typedef struct xfs_dir2_data {
- xfs_dir2_data_hdr_t hdr; /* magic XFS_DIR2_DATA_MAGIC */
- xfs_dir2_data_union_t u[1];
-} xfs_dir2_data_t;
-
-/*
- * Macros.
- */
-
/*
* Size of a data entry.
*/
Index: xfs/fs/xfs/xfs_dir2_leaf.c
===================================================================
--- xfs.orig/fs/xfs/xfs_dir2_leaf.c 2011-06-30 09:38:40.140067486 +0200
+++ xfs/fs/xfs/xfs_dir2_leaf.c 2011-06-30 09:38:41.646734133 +0200
@@ -785,7 +785,6 @@ xfs_dir2_leaf_getdents(
int byteoff; /* offset in current block */
xfs_dir2_db_t curdb; /* db for current block */
xfs_dir2_off_t curoff; /* current overall offset */
- xfs_dir2_data_t *data; /* data block structure */
xfs_dir2_data_hdr_t *hdr; /* data block header */
xfs_dir2_data_entry_t *dep; /* data entry */
xfs_dir2_data_unused_t *dup; /* unused entry */
@@ -1044,13 +1043,12 @@ xfs_dir2_leaf_getdents(
else if (curoff > newoff)
ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
curdb);
- data = bp->data;
- hdr = &data->hdr;
+ hdr = bp->data;
xfs_dir2_data_check(dp, bp);
/*
* Find our position in the block.
*/
- ptr = (char *)&data->u;
+ ptr = (char *)(hdr + 1);
byteoff = xfs_dir2_byte_to_off(mp, curoff);
/*
* Skip past the header.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-07-01 9:46 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-01 9:43 [PATCH 00/27] patch queue for Linux 3.1, V2 Christoph Hellwig
2011-07-01 9:43 ` [PATCH 01/27] xfs: PF_FSTRANS should never be set in ->writepage Christoph Hellwig
2011-07-01 9:43 ` [PATCH 02/27] xfs: re-enable non-blocking behaviour in xfs_map_blocks Christoph Hellwig
2011-07-05 22:35 ` Alex Elder
2011-07-06 6:37 ` Christoph Hellwig
2011-07-06 13:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 03/27] xfs: work around bogus gcc warning in xfs_allocbt_init_cursor Christoph Hellwig
2011-07-01 9:43 ` [PATCH 04/27] xfs: split xfs_setattr Christoph Hellwig
2011-07-01 9:43 ` [PATCH 06/27] xfs: kill xfs_itruncate_start Christoph Hellwig
2011-07-01 9:43 ` [PATCH 07/27] xfs: split xfs_itruncate_finish Christoph Hellwig
2011-07-06 4:35 ` Alex Elder
2011-07-06 8:11 ` Christoph Hellwig
2011-07-06 14:05 ` Alex Elder
2011-07-01 9:43 ` [PATCH 08/27] xfs: improve sync behaviour in the fact of aggressive dirtying Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-06 8:15 ` Christoph Hellwig
2011-07-06 14:59 ` Alex Elder
2011-07-01 9:43 ` [PATCH 09/27] xfs: fix filesystsem freeze race in xfs_trans_alloc Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 10/27] xfs: remove i_transp Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 11/27] xfs: kill the unused struct xfs_sync_work Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 12/27] xfs: factor out xfs_dir2_leaf_find_entry Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 13/27] xfs: cleanup shortform directory inode number handling Christoph Hellwig
2011-07-05 22:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 14/27] xfs: kill struct xfs_dir2_sf Christoph Hellwig
2011-07-06 1:57 ` Dave Chinner
2011-07-06 8:28 ` Christoph Hellwig
2011-07-06 3:24 ` Alex Elder
2011-07-06 8:33 ` Christoph Hellwig
2011-07-06 15:05 ` Alex Elder
2011-07-01 9:43 ` [PATCH 15/27] xfs: cleanup the defintion of struct xfs_dir2_sf_entry Christoph Hellwig
2011-07-06 2:00 ` Dave Chinner
2011-07-06 3:33 ` Alex Elder
2011-07-06 8:34 ` Christoph Hellwig
2011-07-01 9:43 ` [PATCH 16/27] xfs: avoid usage of struct xfs_dir2_block Christoph Hellwig
2011-07-06 2:19 ` Dave Chinner
2011-07-06 8:35 ` Christoph Hellwig
2011-07-06 3:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 17/27] xfs: kill " Christoph Hellwig
2011-07-06 2:31 ` Dave Chinner
2011-07-06 8:37 ` Christoph Hellwig
2011-07-06 15:11 ` Alex Elder
2011-07-06 3:36 ` Alex Elder
2011-07-01 9:43 ` [PATCH 18/27] xfs: avoid usage of struct xfs_dir2_data Christoph Hellwig
2011-07-06 3:02 ` Dave Chinner
2011-07-06 8:43 ` Christoph Hellwig
2011-07-06 3:38 ` Alex Elder
2011-07-06 8:45 ` Christoph Hellwig
2011-07-01 9:43 ` Christoph Hellwig [this message]
2011-07-06 3:05 ` [PATCH 19/27] xfs: kill " Dave Chinner
2011-07-06 3:38 ` Alex Elder
2011-07-01 9:43 ` [PATCH 20/27] xfs: cleanup the defintion of struct xfs_dir2_data_entry Christoph Hellwig
2011-07-06 3:06 ` Dave Chinner
2011-07-06 3:44 ` Alex Elder
2011-07-06 8:48 ` Christoph Hellwig
2011-07-01 9:43 ` [PATCH 21/27] xfs: cleanup struct xfs_dir2_leaf Christoph Hellwig
2011-07-06 3:13 ` Dave Chinner
2011-07-06 3:44 ` Alex Elder
2011-07-01 9:43 ` [PATCH 22/27] xfs: use generic get_unaligned_beXX helpers Christoph Hellwig
2011-07-06 3:44 ` Dave Chinner
2011-07-06 9:07 ` Christoph Hellwig
2011-07-07 8:00 ` Christoph Hellwig
2011-07-06 3:47 ` Alex Elder
2011-07-01 9:43 ` [PATCH 23/27] xfs: remove the unused xfs_bufhash structure Christoph Hellwig
2011-07-06 3:44 ` Dave Chinner
2011-07-06 3:49 ` Alex Elder
2011-07-01 9:43 ` [PATCH 24/27] xfs: clean up buffer locking helpers Christoph Hellwig
2011-07-06 3:47 ` Dave Chinner
2011-07-06 3:55 ` Alex Elder
2011-07-01 9:43 ` [PATCH 25/27] xfs: return the buffer locked from xfs_buf_get_uncached Christoph Hellwig
2011-07-06 3:48 ` Dave Chinner
2011-07-06 3:57 ` Alex Elder
2011-07-01 9:43 ` [PATCH 26/27] xfs: cleanup I/O-related buffer flags Christoph Hellwig
2011-07-06 3:54 ` Dave Chinner
2011-07-06 9:11 ` Christoph Hellwig
2011-07-06 4:09 ` Alex Elder
2011-07-06 9:11 ` Christoph Hellwig
2011-07-01 9:43 ` [PATCH 27/27] xfs: avoid a few disk cache flushes Christoph Hellwig
2011-07-06 3:55 ` Dave Chinner
2011-07-06 4:11 ` Alex Elder
2011-07-06 4:40 ` [PATCH 00/27] patch queue for Linux 3.1, V2 Alex Elder
2011-07-06 6:42 ` Christoph Hellwig
2011-07-06 13:32 ` Alex Elder
2011-07-06 13:43 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110701094606.199361663@bombadil.infradead.org \
--to=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox