From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp1040.oracle.com ([156.151.31.81]:36921 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752198AbcLSV4E (ORCPT ); Mon, 19 Dec 2016 16:56:04 -0500 Date: Mon, 19 Dec 2016 13:55:39 -0800 From: "Darrick J. Wong" To: Amir Goldstein Cc: Jan Kara , "Theodore Ts'o" , Dave Chinner , Chris Mason , Boaz Harrosh , Jaegeuk Kim , Ryusuke Konishi , Mark Fasheh , Evgeniy Dushistov , Miklos Szeredi , Al Viro , linux-fsdevel@vger.kernel.org Subject: Re: [RFC][PATCH 11/11] xfs: use common file type conversion Message-ID: <20161219215539.GD7311@birch.djwong.org> References: <1482178268-22883-1-git-send-email-amir73il@gmail.com> <1482178268-22883-12-git-send-email-amir73il@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482178268-22883-12-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Dec 19, 2016 at 10:11:08PM +0200, Amir Goldstein wrote: > deduplicate the xfs file type conversion implementation. > > xfs readdir code may expose DT_WHT type to user if that > type was set on disk, but xfs code never set a file type > of WHT on disk. > > If it is acceptable to expose to user DT_UNKNOWN in case > WHT type somehow got to disk, then xfs_dir3_filetype_table > could also be replaced with the common fs_dtype() helper. AFAIK XFS has never actually written XFS_DIR3_FT_WHT to disk. I see that overlayfs whiteouts are now some sort of weird chardev with rdev == 0, so I guess overlayfs doesn't either...? --D > > Signed-off-by: Amir Goldstein > --- > fs/xfs/libxfs/xfs_da_format.h | 5 +++-- > fs/xfs/libxfs/xfs_dir2.c | 17 ----------------- > fs/xfs/libxfs/xfs_dir2.h | 6 ------ > fs/xfs/xfs_iops.c | 2 +- > 4 files changed, 4 insertions(+), 26 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h > index 9a492a9..c66c26f 100644 > --- a/fs/xfs/libxfs/xfs_da_format.h > +++ b/fs/xfs/libxfs/xfs_da_format.h > @@ -169,8 +169,9 @@ struct xfs_da3_icnode_hdr { > > /* > * Dirents in version 3 directories have a file type field. Additions to this > - * list are an on-disk format change, requiring feature bits. Valid values > - * are as follows: > + * list are an on-disk format change, requiring feature bits. > + * Values 0..7 should match common file type values in file_type.h. > + * Valid values are as follows: > */ > #define XFS_DIR3_FT_UNKNOWN 0 > #define XFS_DIR3_FT_REG_FILE 1 > diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c > index c58d72c..645a542 100644 > --- a/fs/xfs/libxfs/xfs_dir2.c > +++ b/fs/xfs/libxfs/xfs_dir2.c > @@ -36,23 +36,6 @@ > struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; > > /* > - * @mode, if set, indicates that the type field needs to be set up. > - * This uses the transformation from file mode to DT_* as defined in linux/fs.h > - * for file type specification. This will be propagated into the directory > - * structure if appropriate for the given operation and filesystem config. > - */ > -const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { > - [0] = XFS_DIR3_FT_UNKNOWN, > - [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, > - [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, > - [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, > - [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, > - [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, > - [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, > - [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, > -}; > - > -/* > * ASCII case-insensitive (ie. A-Z) support for directories that was > * used in IRIX. > */ > diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h > index 0197590..f9b9b50 100644 > --- a/fs/xfs/libxfs/xfs_dir2.h > +++ b/fs/xfs/libxfs/xfs_dir2.h > @@ -32,12 +32,6 @@ struct xfs_dir2_data_unused; > extern struct xfs_name xfs_name_dotdot; > > /* > - * directory filetype conversion tables. > - */ > -#define S_SHIFT 12 > -extern const unsigned char xfs_mode_to_ftype[]; > - > -/* > * directory operations vector for encode/decode routines > */ > struct xfs_dir_ops { > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > index 308bebb..c122827 100644 > --- a/fs/xfs/xfs_iops.c > +++ b/fs/xfs/xfs_iops.c > @@ -103,7 +103,7 @@ xfs_dentry_to_name( > { > namep->name = dentry->d_name.name; > namep->len = dentry->d_name.len; > - namep->type = xfs_mode_to_ftype[(mode & S_IFMT) >> S_SHIFT]; > + namep->type = fs_umode_to_ftype(mode); > } > > STATIC void > -- > 2.7.4 >