From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBDE0C282F6 for ; Mon, 21 Jan 2019 08:42:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9A2D20880 for ; Mon, 21 Jan 2019 08:42:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=philpotter-co-uk.20150623.gappssmtp.com header.i=@philpotter-co-uk.20150623.gappssmtp.com header.b="mGQOdMTO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729252AbfAUImg (ORCPT ); Mon, 21 Jan 2019 03:42:36 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38077 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729051AbfAUImf (ORCPT ); Mon, 21 Jan 2019 03:42:35 -0500 Received: by mail-wm1-f68.google.com with SMTP id m22so9911407wml.3 for ; Mon, 21 Jan 2019 00:42:33 -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=z/niV6uorq0C342uVqWAtYbOKURDEEmCAOlGrkMFX1Y=; b=mGQOdMTOAWAhILud3HAIUFQ8PUeyLMN+wXh4AvG9nIYQvLvhn3oiDYmloJ9rlsXD7u HwaAl9y1N4rUKMp2Irovv9BA1RSPidQJla525+yC3bHFkEXh3RAFRxswwkaNtPad4gnn uJNRQg/NL3WMowjNJ5Z4zfYFwdPy8mEJLpylrTii9x1Ubq67cKQF/EmWXVPu6iV/jlUF mmYcWJoYLscYLQd2t8ozD9RUegWDw9SJuy6hFlXhBadudX2qu8bxqOU+PvRynRxGgKUf modWXleI5Uo90qvJEKl+82aC+XbMYzBnMkur0TdThkWWQZ4qY+Jn7mDQXmSY1W2ai20I n+kA== 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=z/niV6uorq0C342uVqWAtYbOKURDEEmCAOlGrkMFX1Y=; b=VmvoqIyTaEkEyTMLZBIj9OGL71GlkSBwZzYkG8cZxyRThW1/IQ56Lbz+4nKGvSTaCL LwBtxEjLdaW5+KCDeZgLgvB9x9zBrtx55Z0No5OB6KR0PpDLpL5og6I/nFnXONRNPV2S hoBiWIJcpo/PyiXVZ/6G4GWM405Y2I246Ak2rbUJ5MKkiO+vXs1gBzXc7rhw7B08KrTF 7vaR14rfBtvx+NA7m8JO/m4g3DcLfSmUSYJykZHlq5ee4NXA4CWUOg805M1U3L+C549Z tpWk+zBF8bpncWZfeniEL6BPPKjC9wlK5yil8kY5Td5rtpSUUfrLmypvBfoOwL2vZNPY ecZA== X-Gm-Message-State: AJcUukdk4X/Zm6MW37w31L209gnc/F0ztHFY/PuNCL/iiy0t01Vaq5cy 43WahKcH51YT+rix9nDz35c5wi/ISVp2DEzc X-Google-Smtp-Source: ALg8bN6PsTnF1lQghpzojW3mYyWQsx5/ESMHUpNC6mEmOX914BinIVwR58KJIRfjnRz5HY7OD8ZJcw== X-Received: by 2002:a1c:9c52:: with SMTP id f79mr8754017wme.118.1548032074086; Sun, 20 Jan 2019 16:54:34 -0800 (PST) Received: from pathfinder ([90.222.17.17]) by smtp.gmail.com with ESMTPSA id v1sm126502479wrw.90.2019.01.20.16.54.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 20 Jan 2019 16:54:33 -0800 (PST) Date: Mon, 21 Jan 2019 00:54:32 +0000 From: Phillip Potter To: mark@fasheh.com Cc: amir73il@gmail.com, viro@zeniv.linux.org.uk, jlbec@evilplan.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [RFC][PATCH v5 05/09] ocfs2: use common file type conversion Message-ID: <20190121005432.GA32351@pathfinder> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 Deduplicate the ocfs2 file type conversion implementation and remove OCFS2_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 Signed-off-by: Amir Goldstein Signed-off-by: Phillip Potter --- fs/ocfs2/dir.c | 20 ++++---------------- fs/ocfs2/ocfs2_fs.h | 28 +--------------------------- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index c121abbdfc7d..85f21caaa6ec 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -69,10 +69,6 @@ #define NAMEI_RA_BLOCKS 4 #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) -static unsigned char ocfs2_filetype_table[] = { - DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK -}; - static int ocfs2_do_extend_dir(struct super_block *sb, handle_t *handle, struct inode *dir, @@ -1718,7 +1714,7 @@ int __ocfs2_add_entry(handle_t *handle, de->rec_len = cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); de = de1; } - de->file_type = OCFS2_FT_UNKNOWN; + de->file_type = FT_UNKNOWN; if (blkno) { de->inode = cpu_to_le64(blkno); ocfs2_set_de_type(de, inode->i_mode); @@ -1803,13 +1799,9 @@ static int ocfs2_dir_foreach_blk_id(struct inode *inode, } offset += le16_to_cpu(de->rec_len); if (le64_to_cpu(de->inode)) { - unsigned char d_type = DT_UNKNOWN; - - if (de->file_type < OCFS2_FT_MAX) - d_type = ocfs2_filetype_table[de->file_type]; - if (!dir_emit(ctx, de->name, de->name_len, - le64_to_cpu(de->inode), d_type)) + le64_to_cpu(de->inode), + fs_ftype_to_dtype(de->file_type))) goto out; } ctx->pos += le16_to_cpu(de->rec_len); @@ -1900,14 +1892,10 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode, break; } if (le64_to_cpu(de->inode)) { - unsigned char d_type = DT_UNKNOWN; - - if (de->file_type < OCFS2_FT_MAX) - d_type = ocfs2_filetype_table[de->file_type]; if (!dir_emit(ctx, de->name, de->name_len, le64_to_cpu(de->inode), - d_type)) { + fs_ftype_to_dtype(de->file_type))) { brelse(bh); return 0; } diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 7071ad0dec90..b86bf5e74348 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h @@ -391,21 +391,6 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { #define OCFS2_HB_LOCAL "heartbeat=local" #define OCFS2_HB_GLOBAL "heartbeat=global" -/* - * OCFS2 directory file types. Only the low 3 bits are used. The - * other bits are reserved for now. - */ -#define OCFS2_FT_UNKNOWN 0 -#define OCFS2_FT_REG_FILE 1 -#define OCFS2_FT_DIR 2 -#define OCFS2_FT_CHRDEV 3 -#define OCFS2_FT_BLKDEV 4 -#define OCFS2_FT_FIFO 5 -#define OCFS2_FT_SOCK 6 -#define OCFS2_FT_SYMLINK 7 - -#define OCFS2_FT_MAX 8 - /* * OCFS2_DIR_PAD defines the directory entries boundaries * @@ -424,17 +409,6 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { #define OCFS2_LINKS_HI_SHIFT 16 #define OCFS2_DX_ENTRIES_MAX (0xffffffffU) -#define S_SHIFT 12 -static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { - [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE, - [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR, - [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV, - [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV, - [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO, - [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK, - [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK, -}; - /* * Convenience casts @@ -1629,7 +1603,7 @@ static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, umode_t mode) { - de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; + de->file_type = fs_umode_to_ftype(mode); } static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd) -- 2.20.1