aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_node.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-08-12 06:50:09 -0400
committerBen Myers <bpm@sgi.com>2013-08-22 09:40:24 -0400
commit0cb97766f2928579f1029ea7b28ae946cdd6fbe1 (patch)
tree4e64fcd122c5b3ddda050e23efc940eaaea4bb9c /fs/xfs/xfs_dir2_node.c
parented56f34f11da4f491680cd39482fd533134fd589 (diff)
xfs: Add read-only support for dirent filetype field
Add support for the file type field in directory entries so that readdir can return the type of the inode the dirent points to to userspace without first having to read the inode off disk. The encoding of the type field is a single byte that is added to the end of the directory entry name length. For all intents and purposes, it appends a "hidden" byte to the name field which contains the type information. As the directory entry is already of dynamic size, helpers are already required to access and decode the direct entry structures. Hence the relevent extraction and iteration helpers are updated to understand the hidden byte. Helpers for reading and writing the filetype field from the directory entries are also added. Only the read helpers are used by this patch. It also adds all the code necessary to read the type information out of the dirents on disk. Further we add the superblock feature bit and helpers to indicate that we understand the on-disk format change. This is not a compatible change - existing kernels cannot read the new format successfully - so an incompatible feature flag is added. We don't yet allow filesystems to mount with this flag yet - that will be added once write support is added. Finally, the code to take the type from the VFS, convert it to an XFS on-disk type and put it into the xfs_name structures passed around is added, but the directory code does not use this field yet. That will be in the next patch. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/xfs_dir2_node.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 18e287deee66..49f1e9ed492c 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -605,7 +605,7 @@ xfs_dir2_leafn_lookup_for_addname(
605 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 605 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
606 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 606 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
607 } 607 }
608 length = xfs_dir2_data_entsize(args->namelen); 608 length = xfs_dir3_data_entsize(mp, args->namelen);
609 /* 609 /*
610 * Loop over leaf entries with the right hash value. 610 * Loop over leaf entries with the right hash value.
611 */ 611 */
@@ -1259,7 +1259,7 @@ xfs_dir2_leafn_remove(
1259 longest = be16_to_cpu(bf[0].length); 1259 longest = be16_to_cpu(bf[0].length);
1260 needlog = needscan = 0; 1260 needlog = needscan = 0;
1261 xfs_dir2_data_make_free(tp, dbp, off, 1261 xfs_dir2_data_make_free(tp, dbp, off,
1262 xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); 1262 xfs_dir3_data_entsize(mp, dep->namelen), &needlog, &needscan);
1263 /* 1263 /*
1264 * Rescan the data block freespaces for bestfree. 1264 * Rescan the data block freespaces for bestfree.
1265 * Log the data block header if needed. 1265 * Log the data block header if needed.
@@ -1711,7 +1711,7 @@ xfs_dir2_node_addname_int(
1711 dp = args->dp; 1711 dp = args->dp;
1712 mp = dp->i_mount; 1712 mp = dp->i_mount;
1713 tp = args->trans; 1713 tp = args->trans;
1714 length = xfs_dir2_data_entsize(args->namelen); 1714 length = xfs_dir3_data_entsize(mp, args->namelen);
1715 /* 1715 /*
1716 * If we came in with a freespace block that means that lookup 1716 * If we came in with a freespace block that means that lookup
1717 * found an entry with our hash value. This is the freespace 1717 * found an entry with our hash value. This is the freespace
@@ -2007,7 +2007,7 @@ xfs_dir2_node_addname_int(
2007 dep->inumber = cpu_to_be64(args->inumber); 2007 dep->inumber = cpu_to_be64(args->inumber);
2008 dep->namelen = args->namelen; 2008 dep->namelen = args->namelen;
2009 memcpy(dep->name, args->name, dep->namelen); 2009 memcpy(dep->name, args->name, dep->namelen);
2010 tagp = xfs_dir2_data_entry_tag_p(dep); 2010 tagp = xfs_dir3_data_entry_tag_p(mp, dep);
2011 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 2011 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
2012 xfs_dir2_data_log_entry(tp, dbp, dep); 2012 xfs_dir2_data_log_entry(tp, dbp, dep);
2013 /* 2013 /*