From patchwork Mon Aug 21 11:55:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9912303 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 E1E46602D8 for ; Mon, 21 Aug 2017 11:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C94DE27FA8 for ; Mon, 21 Aug 2017 11:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE2C6286E4; Mon, 21 Aug 2017 11:55:33 +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.9 required=2.0 tests=BAYES_00,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 64F8727FA8 for ; Mon, 21 Aug 2017 11:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753492AbdHULz3 (ORCPT ); Mon, 21 Aug 2017 07:55:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:32880 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753558AbdHULzX (ORCPT ); Mon, 21 Aug 2017 07:55:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 01B53AD11; Mon, 21 Aug 2017 11:55:19 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 100611E3488; Mon, 21 Aug 2017 13:55:19 +0200 (CEST) From: Jan Kara To: Cc: Wang Shilong , Andreas Dilger , Jan Kara Subject: [PATCH 26/27] fs: Provide __inode_get_bytes() Date: Mon, 21 Aug 2017 13:55:16 +0200 Message-Id: <20170821115517.26542-27-jack@suse.cz> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170821115517.26542-1-jack@suse.cz> References: <20170821115517.26542-1-jack@suse.cz> 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 Provide helper __inode_get_bytes() which assumes i_lock is already acquired. Quota code will need this to be able to use i_lock to protect consistency of quota accounting information and inode usage. Signed-off-by: Jan Kara --- fs/stat.c | 2 +- include/linux/fs.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index c35610845ab1..8a6aa8caf891 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -710,7 +710,7 @@ loff_t inode_get_bytes(struct inode *inode) loff_t ret; spin_lock(&inode->i_lock); - ret = (((loff_t)inode->i_blocks) << 9) + inode->i_bytes; + ret = __inode_get_bytes(inode); spin_unlock(&inode->i_lock); return ret; } diff --git a/include/linux/fs.h b/include/linux/fs.h index 6e1fd5d21248..d6e9ab7f184f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2998,6 +2998,10 @@ void __inode_add_bytes(struct inode *inode, loff_t bytes); void inode_add_bytes(struct inode *inode, loff_t bytes); void __inode_sub_bytes(struct inode *inode, loff_t bytes); void inode_sub_bytes(struct inode *inode, loff_t bytes); +static inline loff_t __inode_get_bytes(struct inode *inode) +{ + return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes; +} loff_t inode_get_bytes(struct inode *inode); void inode_set_bytes(struct inode *inode, loff_t bytes); const char *simple_get_link(struct dentry *, struct inode *,