From patchwork Tue Mar 26 21:39:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10872211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CCD7139A for ; Tue, 26 Mar 2019 21:39:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479C4285FF for ; Tue, 26 Mar 2019 21:39:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AFEA286D1; Tue, 26 Mar 2019 21:39:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1331285FF for ; Tue, 26 Mar 2019 21:39:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732792AbfCZVjf (ORCPT ); Tue, 26 Mar 2019 17:39:35 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34950 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730605AbfCZVj0 (ORCPT ); Tue, 26 Mar 2019 17:39:26 -0400 Received: by mail-wr1-f68.google.com with SMTP id w1so16170011wrp.2 for ; Tue, 26 Mar 2019 14:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=T0sVxNadLS4ldXRvSM1qi/M1cretRrhP/GEGOI8U9Ag=; b=QVAhLwAGewObcu/jijkF4czAcclYJWoDA3szv/xvqUVrLvpPrL/6pJ7E0q9c+0G45n lCCvITP2ys9DgFIrQ7BuNkxkQhdd/p+cbvXxyyIKGgUqCUQjUu5ezM9IbTtNSAVCD3/E tB0BtTK956/Hf1yWtWhMC0MOE+0AUzYbmI+EIOJQdjUnjrTIhViDVy1qkjqtQlGLI2xi VG2xkMOVXbzQMYuqdwyUp9zqx9tYDMZH9Nr6q+4Qoi5LIh4MYdRgE2Ys8F4R+jcp5JxH s75E03DZdeAimnuXUoay4IbqKIKG9HVMDYcziqrnmsqygq8qa5XnEmWkz8C2az8NgWQ+ 6r7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=T0sVxNadLS4ldXRvSM1qi/M1cretRrhP/GEGOI8U9Ag=; b=aVkLcnt5qRQy1ekyIv47jMydIELwnJhEmt5942ea2WS1hKr7xk6z/PKuR1ztcYW6Os 8ZG8DknBToxHx0c2C/BYRYQNeVynMZ8Hf935jXuucNhfbXAXzGv7igc0Zm2a7DoPYJpb F0l+SzMmZ7jiYcwRJHwPUVxLB5OtXvyaEpU+I5Ak5VlpppfzMF2018iPlEaQMWPiOman NXGCJeIhRBV6gYTlholkokyg+nlAAx7PlfPaVymYEmRPxzPssXCTA56soZccDZzxlja4 KQy6uzbzo7HC/ggW2niYoxQ8dBw+SIeX5XQCYOb4Bcp79WeaFaH/0zHw8zxNRmznvY1V vAhA== X-Gm-Message-State: APjAAAVlmPbF12ItL42oUEE6jd7Rptu70yNfmfntsgOH4W+GGDgKEQHl nLuiwBIsMA6GwxTpPeFIZiHT/paPPxaVfw== X-Google-Smtp-Source: APXvYqzuR8Pq5gl5vwHImVN0VwxXdN9qgv09nvrTDLJK2H8qSNGqAI0Z5JGE6H9U8NjSI6RZmDPqFg== X-Received: by 2002:adf:f60e:: with SMTP id t14mr18407514wrp.39.1553636364324; Tue, 26 Mar 2019 14:39:24 -0700 (PDT) Received: from pathfinder ([90.195.158.41]) by smtp.gmail.com with ESMTPSA id g19sm7660274wmh.17.2019.03.26.14.39.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 26 Mar 2019 14:39:23 -0700 (PDT) Date: Tue, 26 Mar 2019 21:39:22 +0000 From: Phillip Potter To: jaegeuk@kernel.org Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Subject: [PATCH v6 04/07] f2fs: use common file type conversion Message-ID: <20190326213922.GA20879@pathfinder> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Deduplicate the f2fs file type conversion implementation and remove F2FS_FT_* definitions - file systems that use the same file types as defined by POSIX do not need to define their own versions and can use the common helper functions decared in fs_types.h and implemented in fs_types.c Common implementation can be found via commit: bbe7449e2599 "fs: common implementation of file type" Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter Reviewed-by: Chao Yu Reviewed-by: Jan Kara --- fs/f2fs/dir.c | 27 ++------------------------- fs/f2fs/inline.c | 2 +- include/linux/f2fs_fs.h | 15 --------------- 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 59bc46017855..bcac1bb7fad2 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -36,37 +36,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, -}; - static 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 f2fs_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_ftype_to_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 bb6a152310ef..cd935329e2d1 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -458,7 +458,7 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry) new_name.len = le16_to_cpu(de->name_len); ino = le32_to_cpu(de->ino); - fake_mode = f2fs_get_de_type(de) << S_SHIFT; + fake_mode = f2fs_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 f5740423b002..2f85d4d739b0 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h @@ -526,21 +526,6 @@ struct f2fs_dentry_block { __u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN]; } __packed; -/* file types used in inode_info->flags */ -enum { - F2FS_FT_UNKNOWN, - F2FS_FT_REG_FILE, - F2FS_FT_DIR, - F2FS_FT_CHRDEV, - F2FS_FT_BLKDEV, - F2FS_FT_FIFO, - F2FS_FT_SOCK, - F2FS_FT_SYMLINK, - F2FS_FT_MAX -}; - -#define S_SHIFT 12 - #define F2FS_DEF_PROJID 0 /* default project ID */ #endif /* _LINUX_F2FS_FS_H */