From patchwork Fri Nov 17 16:57:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10063019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 447A66023A for ; Fri, 17 Nov 2017 16:57:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32D7C2A9D9 for ; Fri, 17 Nov 2017 16:57:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27C662AD35; Fri, 17 Nov 2017 16:57:09 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 7D7F52A9D9 for ; Fri, 17 Nov 2017 16:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759333AbdKQQ5H (ORCPT ); Fri, 17 Nov 2017 11:57:07 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:34650 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbdKQQ5H (ORCPT ); Fri, 17 Nov 2017 11:57:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=d8b9RvZrYHNhLF/J+Vh6pC65DluSqKgdQOCYQl3f31c=; b=J8dzQ5hZPnD57X73KlRcm2y3E UuwxlMaOboBV2jkM+QOcM9b3j3/rrlxXSt5C8YmWCzv9eRJTJexxuaVEeSW9hyXMOOHOp8RrB+XNA VDQqF0gkVFprDY4xxE8Iub2CFAgQI6Tdez9wG742O28Pp8ceX6yMDDB/BB9dChjLN/YgQFp5qUHMF fNhKzOuElN5+6omBoNRCI1UQxPo4c6qtRwoAjyck+X/4t8cPMvHggtkYc3dfz/iaKPd8zaxw6+1c/ FApYJYi1fl+uhfGM4suuBcGA5ve1j7J4J77/N/1iEikoMiuTWgabL+1CUzNXk0VuZ66TKjeUrFSAk qrqHrbZRg==; Received: from hch by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eFjww-0002NY-1Y; Fri, 17 Nov 2017 16:57:06 +0000 Date: Fri, 17 Nov 2017 08:57:06 -0800 From: Christoph Hellwig To: "Darrick J. Wong" Cc: Eric Sandeen , xfs Subject: Re: [PATCH for 4.15] libxfs: fix dev_t handling in inode forks Message-ID: <20171117165706.GB17447@infradead.org> References: <20171116011505.GH5119@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171116011505.GH5119@magnolia> User-Agent: Mutt/1.8.3 (2017-05-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hmm. I guess we should just clean up the calling conventions, and keep the conversion helpers in xfs_linux.h so that xfsprogs can turn them into noops. Something like the untested patch for the kernel space, xfsprogs would then just stub out the two inlines to return the passed in value. --- From e0ed26ab66774c1611e71a3c290efbe4e21d483c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 17 Nov 2017 17:55:48 +0100 Subject: xfs: abstract out dev_t conversions And move them to xfs_linux.h so that xfsprogs can stub them out more easily. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_inode_fork.c | 8 ++------ fs/xfs/xfs_linux.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 1c90ec41e9df..c79a1616b79d 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -42,11 +42,6 @@ STATIC int xfs_iformat_local(xfs_inode_t *, xfs_dinode_t *, int, int); STATIC int xfs_iformat_extents(xfs_inode_t *, xfs_dinode_t *, int); STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int); -static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) -{ - return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); -} - /* * Copy inode type and data and attr format specific information from the * on-disk inode to the in-core inode and fork structures. For fifos, devices, @@ -792,7 +787,8 @@ xfs_iflush_fork( case XFS_DINODE_FMT_DEV: if (iip->ili_fields & XFS_ILOG_DEV) { ASSERT(whichfork == XFS_DATA_FORK); - xfs_dinode_put_rdev(dip, sysv_encode_dev(VFS_I(ip)->i_rdev)); + xfs_dinode_put_rdev(dip, + linux_to_xfs_dev_t(VFS_I(ip)->i_rdev)); } break; diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 6282bfc1afa9..99562ec0de56 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -204,6 +204,16 @@ static inline kgid_t xfs_gid_to_kgid(uint32_t gid) return make_kgid(&init_user_ns, gid); } +static inline dev_t xfs_to_linux_dev_t(xfs_dev_t dev) +{ + return MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev)); +} + +static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev) +{ + return sysv_encode_dev(dev); +} + /* * Various platform dependent calls that don't fit anywhere else */