From patchwork Sun Dec 2 11:38:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10707983 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 E86171057 for ; Sun, 2 Dec 2018 11:38:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9FFC2AE9F for ; Sun, 2 Dec 2018 11:38:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE8332AEBA; Sun, 2 Dec 2018 11:38:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 726282AE9F for ; Sun, 2 Dec 2018 11:38:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbeLBLiy (ORCPT ); Sun, 2 Dec 2018 06:38:54 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:35430 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbeLBLiy (ORCPT ); Sun, 2 Dec 2018 06:38:54 -0500 Received: by mail-wm1-f68.google.com with SMTP id c126so2969364wmh.0 for ; Sun, 02 Dec 2018 03:38:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TU9K2/5433IALLbVPgIjT+jq/QNz+z4RrCLfSCroAd0=; b=cyQSgChZKtka1CFENFNdtaG09edaJkPiRNk8Stzel6arNnZyGZryOe4mxDzfJROuTu r9XzCvjZrWdzH6j6D6gGMD8kATru+J9ZXHDWQ1P33dZOrvtFQ5REzD5qynd4Hr+a1i/L DKYrf/mS5DblfBlbsje+mw31KaTkus1HxvCQdOt+reqa5pLLcHCA2a75/gaZwjh8cI7D 4e80F5h4DQICQfeYJ1Pw+Me2PdC9K5Trl2Ld/fqVDb7xNK/O1P8XPd3NrEsyNXNA8kAn PcLb6v34hBQeEocTaF9JXITrqO16kaRTyFqwBjZweHNKKhOKekgDwNKvJ+Da74nl39hC 4I0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TU9K2/5433IALLbVPgIjT+jq/QNz+z4RrCLfSCroAd0=; b=ODmhDiq7kJryxdThu34tCJQc4C8Kur3TX9SOhV7J1nx/6QG0CRIgPnL/Bp8x0FSxMz FOr4pgKlniXd13zj/Q5UUYToRTPgQSL2t+npD1duY0Zhb21Nqv9fXE6uEtrqA+1RImIO zp0y56R2Ytowlfg7qdrK72eBL9L+CNkZYA8fNiIWA4f1L0IcpxrWkZYwfyjePFKvDm16 F/nQoxa9BjQBDpalTJrgGzpbZA51CStEnKOW3VpK9DdC22BLmPahBJFWnX8Fb2FVovIF T/5u6L086VP+caOarZcRCm9b885YgtK9Aotd3NkKiSjYWejsTKUZtXy9e6cTConkW1tc Zr7g== X-Gm-Message-State: AA+aEWaHEEiKxS+acKVotVwAKGLHknAILBwANWpMknIkulwncOZXZt3p g8DIp7SmhNs/SbuVZSkuYdEW+6zH X-Google-Smtp-Source: AFSGD/U0JkCCVJEl9OtvpQtCZgpcAFv4ZL1yE+56dCh6SsopORgDlAg8LSys/xDz+XWPZxj/sbytew== X-Received: by 2002:a1c:d78b:: with SMTP id o133mr4401901wmg.121.1543750730493; Sun, 02 Dec 2018 03:38:50 -0800 (PST) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id c3-v6sm3448672wmb.46.2018.12.02.03.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Dec 2018 03:38:50 -0800 (PST) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH v4 11/15] fanotify: use vfs_get_fsid() helper instead of vfs_statfs() Date: Sun, 2 Dec 2018 13:38:22 +0200 Message-Id: <20181202113826.32133-12-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181202113826.32133-1-amir73il@gmail.com> References: <20181202113826.32133-1-amir73il@gmail.com> 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 This is a cleanup that doesn't change any logic. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify_user.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index b69a7c23a765..8ecd9db8931c 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -855,35 +855,31 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) } /* Check if filesystem can encode a unique fid */ -static int fanotify_test_fid(struct path *path, struct kstatfs *stat) +static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid) { - struct kstatfs root_stat; - struct path root = { - .mnt = path->mnt, - .dentry = path->dentry->d_sb->s_root, - }; + __kernel_fsid_t root_fsid; int err; /* * Make sure path is not in filesystem with zero fsid (e.g. tmpfs). */ - err = vfs_statfs(path, stat); + err = vfs_get_fsid(path->dentry, fsid); if (err) return err; - if (!stat->f_fsid.val[0] && !stat->f_fsid.val[1]) + if (!fsid->val[0] && !fsid->val[1]) return -ENODEV; /* * Make sure path is not inside a filesystem subvolume (e.g. btrfs) * which uses a different fsid than sb root. */ - err = vfs_statfs(&root, &root_stat); + err = vfs_get_fsid(path->dentry->d_sb->s_root, &root_fsid); if (err) return err; - if (root_stat.f_fsid.val[0] != stat->f_fsid.val[0] || - root_stat.f_fsid.val[1] != stat->f_fsid.val[1]) + if (root_fsid.val[0] != fsid->val[0] || + root_fsid.val[1] != fsid->val[1]) return -EXDEV; /* @@ -908,8 +904,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, struct fsnotify_group *group; struct fd f; struct path path; - struct kstatfs stat; - __kernel_fsid_t *fsid = NULL; + __kernel_fsid_t __fsid, *fsid = NULL; u32 valid_mask = FANOTIFY_EVENTS | FANOTIFY_EVENT_FLAGS; unsigned int mark_type = flags & FANOTIFY_MARK_TYPE_BITS; int ret; @@ -988,11 +983,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, goto fput_and_out; if (FAN_GROUP_FLAG(group, FAN_REPORT_FID)) { - ret = fanotify_test_fid(&path, &stat); + ret = fanotify_test_fid(&path, &__fsid); if (ret) goto path_put_and_out; - fsid = &stat.f_fsid; + fsid = &__fsid; } /* inode held in place by reference to path; group by fget on fd */