From patchwork Thu Jan 17 07:53:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10767673 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 55FCD139A for ; Thu, 17 Jan 2019 07:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB932F06A for ; Thu, 17 Jan 2019 07:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F31B2F073; Thu, 17 Jan 2019 07:53:27 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 E08802F06A for ; Thu, 17 Jan 2019 07:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbfAQHx0 (ORCPT ); Thu, 17 Jan 2019 02:53:26 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:35030 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbfAQHxZ (ORCPT ); Thu, 17 Jan 2019 02:53:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EmkjGqAIv4suFaKTqTxPErhZHBRn1niRLB8tCN5s8ok=; b=iQli5SOpTZ31anXfbz0BlCQ4c epvrN/wlwrLePH0gTV32qr3DbDqEPr6D6nSrwtlSd6xmKkpp2gyYKKxJ7eHctFNC1UM690o9fXOEE AqTV0yQ//0aA+gSDpflNUvZui884Gg8q53djZ836ZJs+S73EzDaEOSuWdRAX5InBGWsBPPf7VCq87 OJkuqYbcoU9hmvis/kTIDhbDj9eXqciRvfqAa18Mn9n27nppXdXNhSCASzD5tEk7NAhDKXXwEAC5E ASzyRKiRS1uDJZn9LjJJWrXBzLbZE5LnShYkXqVd2X/PrCX2SlyAhA5IDLrrHf+rKNZzE/2h+p321 dTSLJkGrg==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gk2UN-0007Dx-8R; Thu, 17 Jan 2019 07:53:23 +0000 From: Christoph Hellwig To: viro@zeniv.linux.org.uk, dhowells@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH] fs: move generic stat response attr handling to vfs_getattr_nosec Date: Thu, 17 Jan 2019 08:53:20 +0100 Message-Id: <20190117075320.8327-1-hch@lst.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 generic_fillattr is an optional helper that isn't used by all file systems, move handling purely based on inode flags to vfs_getattr_nosec, which is common code. This fixes setting this flag for file systems not using generic_fillattr like xfs. Signed-off-by: Christoph Hellwig --- fs/stat.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index adbfcd86c81b..9600ff1ea8df 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -45,11 +45,6 @@ void generic_fillattr(struct inode *inode, struct kstat *stat) stat->ctime = inode->i_ctime; stat->blksize = i_blocksize(inode); stat->blocks = inode->i_blocks; - - if (IS_NOATIME(inode)) - stat->result_mask &= ~STATX_ATIME; - if (IS_AUTOMOUNT(inode)) - stat->attributes |= STATX_ATTR_AUTOMOUNT; } EXPORT_SYMBOL(generic_fillattr); @@ -75,11 +70,19 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, stat->result_mask |= STATX_BASIC_STATS; request_mask &= STATX_ALL; query_flags &= KSTAT_QUERY_FLAGS; - if (inode->i_op->getattr) - return inode->i_op->getattr(path, stat, request_mask, - query_flags); + if (inode->i_op->getattr) { + int ret = inode->i_op->getattr(path, stat, request_mask, + query_flags); + if (ret) + return ret; + } else { + generic_fillattr(inode, stat); + } - generic_fillattr(inode, stat); + if (IS_NOATIME(inode)) + stat->result_mask &= ~STATX_ATIME; + if (IS_AUTOMOUNT(inode)) + stat->attributes |= STATX_ATTR_AUTOMOUNT; return 0; } EXPORT_SYMBOL(vfs_getattr_nosec);