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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 2BFFAC35DF5 for ; Tue, 25 Feb 2020 13:46:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F335C2467D for ; Tue, 25 Feb 2020 13:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730308AbgBYNqP (ORCPT ); Tue, 25 Feb 2020 08:46:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:45678 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729721AbgBYNqP (ORCPT ); Tue, 25 Feb 2020 08:46:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D3D92AD03; Tue, 25 Feb 2020 13:46:13 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 2553F1E0EA2; Tue, 25 Feb 2020 14:46:12 +0100 (CET) Date: Tue, 25 Feb 2020 14:46:12 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 02/16] fsnotify: factor helpers fsnotify_dentry() and fsnotify_file() Message-ID: <20200225134612.GA10728@quack2.suse.cz> References: <20200217131455.31107-1-amir73il@gmail.com> <20200217131455.31107-3-amir73il@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200217131455.31107-3-amir73il@gmail.com> 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 On Mon 17-02-20 15:14:41, Amir Goldstein wrote: > Most of the code in fsnotify hooks is boiler plate of one or the other. > > Signed-off-by: Amir Goldstein > --- > include/linux/fsnotify.h | 96 +++++++++++++++------------------------- > 1 file changed, 36 insertions(+), 60 deletions(-) Nice cleanup. Just two comments below. > @@ -58,8 +78,6 @@ static inline int fsnotify_path(struct inode *inode, const struct path *path, > static inline int fsnotify_perm(struct file *file, int mask) > { > int ret; > - const struct path *path = &file->f_path; > - struct inode *inode = file_inode(file); > __u32 fsnotify_mask = 0; > > if (file->f_mode & FMODE_NONOTIFY) I guess you can drop the NONOTIFY check from here. You've moved it to fsnotify_file() and there's not much done in this function to be worth skipping... > @@ -70,7 +88,7 @@ static inline int fsnotify_perm(struct file *file, int mask) > fsnotify_mask = FS_OPEN_PERM; > > if (file->f_flags & __FMODE_EXEC) { > - ret = fsnotify_path(inode, path, FS_OPEN_EXEC_PERM); > + ret = fsnotify_file(file, FS_OPEN_EXEC_PERM); > > if (ret) > return ret; Hum, I think we could simplify fsnotify_perm() even further by having: if (mask & MAY_OPEN) { if (file->f_flags & __FMODE_EXEC) fsnotify_mask = FS_OPEN_EXEC_PERM; else fsnotify_mask = FS_OPEN_PERM; } ... Otherwise the patch looks good to me. Honza -- Jan Kara SUSE Labs, CR