From patchwork Mon Jan 21 00:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 10772845 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 0DB276C2 for ; Mon, 21 Jan 2019 08:01:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F332829D62 for ; Mon, 21 Jan 2019 08:01:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E707329D67; Mon, 21 Jan 2019 08:01:34 +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=-6.4 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, 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 8107929D62 for ; Mon, 21 Jan 2019 08:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbfAUIBd (ORCPT ); Mon, 21 Jan 2019 03:01:33 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:47032 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729119AbfAUIBc (ORCPT ); Mon, 21 Jan 2019 03:01:32 -0500 Received: by mail-wr1-f66.google.com with SMTP id l9so22031411wrt.13 for ; Mon, 21 Jan 2019 00:01:31 -0800 (PST) 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=GPJFHkvNVUYGWUif3SNSEtU8iMpkiMe9hRfFKZgGxFQ=; b=mQkKOq2MgH7QrCk3XxsrWSnKOqSWvAnORAMmjBmxU0qDB6EhFXXjOVzLBpMEcX/99w Tb4JxvV5+3/kIVoXMRVW8mo3sJh9UFZcXTWoukC6ooZBoO5VXZpYfhLizsZEWtCZPso6 LlLx0x83h4OBw7IoChuWp1jVrVBWllc+xcxSrbQ1+f2r4jn9NMqUS5XyytjraNxAMz0I 8IFsMscQ19RTJAkooeQilkAasKQRqQEzAe0wQcimMIAHvplFyyX3Nyk/5H9ZDdM7c0MV UhOOSsIohOr6NFPNZ0JxMAr0VWJwILJQn6yqIN9JKwlTne1n4oCY6D0X/8+JDxVzqOBL Xk6w== 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=GPJFHkvNVUYGWUif3SNSEtU8iMpkiMe9hRfFKZgGxFQ=; b=Q+V5nnNs23M6MEU0KiSMYmRIR5pcm8ndJPc4YC2gN8oe9QM2Kc15knwtW8vi6/omL9 eI+0zg5rcfbeJQiEbnInuHUAXturkjXRrKsItdLU+eC6A49eaNIqB7ww69XTytlD8ElT 6ypjeJvyDU1MwIPAZaro78qI5bPAGPF3XHdGwgAYc1ReMpkcAq18b2y6bNjFchVommm+ RyFrtv7aAMQlwVWroLJVH/r/m0MGHY9VXDFeoLxXQ+y70Hvou7AJRtRRnN/OYbyS4bCa IqZWDSJqzevpPk/wMoRhRZpnWiBOk51WbcRwEKD+1grSM9PmUShzOFpfxHzbrCbumjgD NWJQ== X-Gm-Message-State: AJcUukemNmPZfjEPyCEmrwapOFjuRoc/tB4YTCPU/3sITgQdwx2LV1YP fnlOnEOGjmniJ1387HkCGzuYr0lg8Ymz8h8k X-Google-Smtp-Source: ALg8bN6xt++620FobN8wu20+Gfpy7fhG8jh94x58XBe0q/PF2oc9ESuOWnYwJe7eYn5wszEEGoLl8Q== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr25252240wrq.38.1548032076513; Sun, 20 Jan 2019 16:54:36 -0800 (PST) Received: from pathfinder ([90.222.17.17]) by smtp.gmail.com with ESMTPSA id g67sm101303111wmd.38.2019.01.20.16.54.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 20 Jan 2019 16:54:35 -0800 (PST) Date: Mon, 21 Jan 2019 00:54:35 +0000 From: Phillip Potter To: tytso@mit.edu Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH v5 07/09] ext4: use common file type conversion Message-ID: <20190121005435.GA32365@pathfinder> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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 ext4 file type conversion implementation and define EXT4_FT_* to match shared FT_* - 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 Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 185a05d3257e..f43d002a30fd 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1925,16 +1925,16 @@ struct ext4_dir_entry_tail { * Ext4 directory file types. Only the low 3 bits are used. The * other bits are reserved for now. */ -#define EXT4_FT_UNKNOWN 0 -#define EXT4_FT_REG_FILE 1 -#define EXT4_FT_DIR 2 -#define EXT4_FT_CHRDEV 3 -#define EXT4_FT_BLKDEV 4 -#define EXT4_FT_FIFO 5 -#define EXT4_FT_SOCK 6 -#define EXT4_FT_SYMLINK 7 +#define EXT4_FT_UNKNOWN FT_UNKNOWN +#define EXT4_FT_REG_FILE FT_REG_FILE +#define EXT4_FT_DIR FT_DIR +#define EXT4_FT_CHRDEV FT_CHRDEV +#define EXT4_FT_BLKDEV FT_BLKDEV +#define EXT4_FT_FIFO FT_FIFO +#define EXT4_FT_SOCK FT_SOCK +#define EXT4_FT_SYMLINK FT_SYMLINK -#define EXT4_FT_MAX 8 +#define EXT4_FT_MAX FT_MAX #define EXT4_FT_DIR_CSUM 0xDE @@ -2357,16 +2357,13 @@ static inline void ext4_update_dx_flag(struct inode *inode) if (!ext4_has_feature_dir_index(inode->i_sb)) ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); } -static const unsigned char ext4_filetype_table[] = { - DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK -}; static inline unsigned char get_dtype(struct super_block *sb, int filetype) { - if (!ext4_has_feature_filetype(sb) || filetype >= EXT4_FT_MAX) + if (!ext4_has_feature_filetype(sb)) return DT_UNKNOWN; - return ext4_filetype_table[filetype]; + return fs_ftype_to_dtype(filetype); } extern int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf, int buf_size); @@ -3065,22 +3062,12 @@ extern void initialize_dirent_tail(struct ext4_dir_entry_tail *t, extern int ext4_handle_dirty_dirent_node(handle_t *handle, struct inode *inode, struct buffer_head *bh); -#define S_SHIFT 12 -static const unsigned char ext4_type_by_mode[(S_IFMT >> S_SHIFT) + 1] = { - [S_IFREG >> S_SHIFT] = EXT4_FT_REG_FILE, - [S_IFDIR >> S_SHIFT] = EXT4_FT_DIR, - [S_IFCHR >> S_SHIFT] = EXT4_FT_CHRDEV, - [S_IFBLK >> S_SHIFT] = EXT4_FT_BLKDEV, - [S_IFIFO >> S_SHIFT] = EXT4_FT_FIFO, - [S_IFSOCK >> S_SHIFT] = EXT4_FT_SOCK, - [S_IFLNK >> S_SHIFT] = EXT4_FT_SYMLINK, -}; static inline void ext4_set_de_type(struct super_block *sb, struct ext4_dir_entry_2 *de, umode_t mode) { if (ext4_has_feature_filetype(sb)) - de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; + de->file_type = fs_umode_to_ftype(mode); } /* readpages.c */