linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.com>, Theodore Ts'o <tytso@mit.edu>,
	Dave Chinner <david@fromorbit.com>
Cc: "Darrick J . Wong" <darrick.wong@oracle.com>,
	Chris Mason <clm@fb.com>, Boaz Harrosh <boaz@plexistor.com>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>,
	Mark Fasheh <mfasheh@versity.com>,
	Evgeniy Dushistov <dushistov@mail.ru>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org
Subject: [RFC][PATCH 08/11] f2fs: use common file type conversion
Date: Mon, 19 Dec 2016 22:11:05 +0200	[thread overview]
Message-ID: <1482178268-22883-9-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1482178268-22883-1-git-send-email-amir73il@gmail.com>

deduplicate the f2fs file type conversion implementation.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/f2fs/dir.c           | 27 ++-------------------------
 fs/f2fs/inline.c        |  2 +-
 include/linux/f2fs_fs.h |  8 +++++---
 3 files changed, 8 insertions(+), 29 deletions(-)

diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 827c5da..31bbad1 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -37,37 +37,14 @@ static unsigned int bucket_blocks(unsigned int level)
 		return 4;
 }
 
-static unsigned char f2fs_filetype_table[F2FS_FT_MAX] = {
-	[F2FS_FT_UNKNOWN]	= DT_UNKNOWN,
-	[F2FS_FT_REG_FILE]	= DT_REG,
-	[F2FS_FT_DIR]		= DT_DIR,
-	[F2FS_FT_CHRDEV]	= DT_CHR,
-	[F2FS_FT_BLKDEV]	= DT_BLK,
-	[F2FS_FT_FIFO]		= DT_FIFO,
-	[F2FS_FT_SOCK]		= DT_SOCK,
-	[F2FS_FT_SYMLINK]	= DT_LNK,
-};
-
-static unsigned char f2fs_type_by_mode[S_IFMT >> S_SHIFT] = {
-	[S_IFREG >> S_SHIFT]	= F2FS_FT_REG_FILE,
-	[S_IFDIR >> S_SHIFT]	= F2FS_FT_DIR,
-	[S_IFCHR >> S_SHIFT]	= F2FS_FT_CHRDEV,
-	[S_IFBLK >> S_SHIFT]	= F2FS_FT_BLKDEV,
-	[S_IFIFO >> S_SHIFT]	= F2FS_FT_FIFO,
-	[S_IFSOCK >> S_SHIFT]	= F2FS_FT_SOCK,
-	[S_IFLNK >> S_SHIFT]	= F2FS_FT_SYMLINK,
-};
-
 void set_de_type(struct f2fs_dir_entry *de, umode_t mode)
 {
-	de->file_type = f2fs_type_by_mode[(mode & S_IFMT) >> S_SHIFT];
+	de->file_type = fs_umode_to_ftype(mode);
 }
 
 unsigned char get_de_type(struct f2fs_dir_entry *de)
 {
-	if (de->file_type < F2FS_FT_MAX)
-		return f2fs_filetype_table[de->file_type];
-	return DT_UNKNOWN;
+	return fs_dtype(de->file_type);
 }
 
 static unsigned long dir_block_index(unsigned int level,
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index e32a9e5..53148d6 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -424,7 +424,7 @@ static int f2fs_add_inline_entries(struct inode *dir,
 		new_name.len = le16_to_cpu(de->name_len);
 
 		ino = le32_to_cpu(de->ino);
-		fake_mode = get_de_type(de) << S_SHIFT;
+		fake_mode = get_de_type(de) << S_DT_SHIFT;
 
 		err = f2fs_add_regular_entry(dir, &new_name, NULL, NULL,
 							ino, fake_mode);
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index cea41a1..3bfa4e2 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -504,7 +504,11 @@ struct f2fs_inline_dentry {
 	__u8 filename[NR_INLINE_DENTRY][F2FS_SLOT_LEN];
 } __packed;
 
-/* file types used in inode_info->flags */
+/*
+ * file types used in inode_info->flags
+ *
+ * Values should match common file type values in file_type.h.
+ */
 enum {
 	F2FS_FT_UNKNOWN,
 	F2FS_FT_REG_FILE,
@@ -517,6 +521,4 @@ enum {
 	F2FS_FT_MAX
 };
 
-#define S_SHIFT 12
-
 #endif  /* _LINUX_F2FS_FS_H */
-- 
2.7.4


  parent reply	other threads:[~2016-12-19 20:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 20:10 [RFC][PATCH 00/11] common implementation of dirent file types Amir Goldstein
2016-12-19 20:10 ` [RFC][PATCH 01/11] fs: common implementation of file type conversions Amir Goldstein
2016-12-19 21:13   ` Darrick J. Wong
2016-12-20  5:01     ` Amir Goldstein
2016-12-20  7:37   ` [RFC][PATCH v2 " Amir Goldstein
2016-12-19 20:10 ` [RFC][PATCH 02/11] ufs: use fs_umode_to_dtype() helper Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 03/11] hfsplus: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 04/11] ext2: use common file type conversion Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 05/11] exofs: " Amir Goldstein
2016-12-19 21:50   ` Boaz Harrosh
2016-12-19 20:11 ` [RFC][PATCH 06/11] ext4: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 07/11] ocfs2: " Amir Goldstein
2016-12-19 20:11 ` Amir Goldstein [this message]
2016-12-19 20:11 ` [RFC][PATCH 09/11] nilfs2: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 10/11] btrfs: " Amir Goldstein
2016-12-19 20:11 ` [RFC][PATCH 11/11] xfs: " Amir Goldstein
2016-12-19 21:55   ` Darrick J. Wong
2016-12-20  6:17     ` Amir Goldstein
2016-12-20 14:07       ` Amir Goldstein
2016-12-20  0:28   ` Darrick J. Wong
2016-12-20  5:20     ` Amir Goldstein
2016-12-21  5:23       ` Dave Chinner
2016-12-21  6:37         ` Amir Goldstein
2016-12-21 10:12           ` [RFC][PATCH v2 " Amir Goldstein
2016-12-21 18:01             ` [PATCH v3 " Amir Goldstein
2016-12-22 21:07               ` [PATCH v4] xfs: fix the size of xfs_mode_to_ftype table Amir Goldstein
2016-12-23 21:01                 ` Darrick J. Wong
2016-12-24  7:31                   ` Amir Goldstein
2016-12-24 14:11                 ` Brian Foster
2016-12-21 15:06         ` [RFC][PATCH 11/11] xfs: use common file type conversion Theodore Ts'o
2016-12-21 16:37           ` Amir Goldstein
2016-12-21 22:56             ` Theodore Ts'o
2016-12-22  5:54               ` Amir Goldstein
2016-12-22 20:30                 ` Amir Goldstein
2016-12-21 16:59           ` Miklos Szeredi

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=1482178268-22883-9-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=boaz@plexistor.com \
    --cc=clm@fb.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=dushistov@mail.ru \
    --cc=jack@suse.com \
    --cc=jaegeuk@kernel.org \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mfasheh@versity.com \
    --cc=miklos@szeredi.hu \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).