Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp335276pxv; Thu, 8 Jul 2021 03:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA799pQoJub6iTgT3AjQhETsbj8dQenw5HOdcKDx4jh0kpvHOM47A8SXCb8FtLKSsbJUTD X-Received: by 2002:a05:6402:90d:: with SMTP id g13mr17918376edz.47.1625741032864; Thu, 08 Jul 2021 03:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625741032; cv=none; d=google.com; s=arc-20160816; b=j5z5cuR7UXDdMFmup/7ZIG/h/xKM6zDp7RcPGyL9n2jyCRx4vU1SoUYL8hqw2ETEVW WjuINs4iq/9vAduVsHtDwQK0bmcBqmWur6qve2EHaUsdOX8/YmDvJG8awSkecOZTfP5z I114dRmUkz74NjDSar91ulZVV1QxdFfvHmJn11o7LjduM5f1YgC/L4itHE90lwOfkXl4 D1oAPd/W9urX1OmiVEVUCDz63nTxSU1r76DiuMpqDNIBPiMOgtFW7fVwf3Uc+7lluyHq m/3zVEt2EGkp08CxDC9BoZ2YUmeuGJZeCdRehjpUbqbf69Kiz9cX+eLtsxpgAJal563a R9bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=EJ1HsFHAAfuSfErssxtfv8nLSrzDHxYtuYvwU40BOaE=; b=RugQywg8mErvSpdWMk6nxldez8ORZMWI568wpsEszwjImAAICX2NnrOdt2KfXH/aVp LU36Vzl2YEEAPJfRpDQBfwo+Pp3IMGI+Y+bcGnd6FCe2enNnV664t/Cf53T+2gKQp4ZZ zFfNqA5X6piRGEsbNwJFy6mMqjWLcrYqfKNATePu/4Zf75VyDxRxf8BuuIXdMyMrCngY DmvMHjiXZgQ/YutyHWZzYSjaqxwUQcED4Z/Wi40enZeBA7K7WgAGlFq7StizNqM2gg/1 m0WLD/U/Sl9oZ61EP/MrrJUGHnFezYMHh8gBbCCetTyGkPGd9mUFRtHceAX9lVhB3viy gNMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TfwGZXcR; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa31si2987843ejc.202.2021.07.08.03.43.18; Thu, 08 Jul 2021 03:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TfwGZXcR; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbhGHKpu (ORCPT + 99 others); Thu, 8 Jul 2021 06:45:50 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:48804 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbhGHKpu (ORCPT ); Thu, 8 Jul 2021 06:45:50 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 9DDBF22093; Thu, 8 Jul 2021 10:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625740987; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EJ1HsFHAAfuSfErssxtfv8nLSrzDHxYtuYvwU40BOaE=; b=TfwGZXcRwOOYhQKpddWlAvoyMgSl8PoBCt+Za4uoikhnKM8Y14sxxWVJAxToKpSrCjKats tMgXyOqQe0WwGxiY2pHYIi5gRGe+2SNgUpea2tbwQZ2ZmnQBQjqUh47p5tAXudxM0gVJpx kNuVzpGCdQhBhmuah6DSfQimUv0klwc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625740987; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EJ1HsFHAAfuSfErssxtfv8nLSrzDHxYtuYvwU40BOaE=; b=82tiE2FgNh75xHjaoPtqomIHk5BJNp45e1KhOE7pvO1z2EUfGq4fs0p2n0Dp+dwwVFOH2F JknqYTT0M7xLkhBQ== Received: from quack2.suse.cz (unknown [10.163.43.118]) by relay2.suse.de (Postfix) with ESMTP id 819A6A3B85; Thu, 8 Jul 2021 10:43:07 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 62EB91E62E4; Thu, 8 Jul 2021 12:43:07 +0200 (CEST) Date: Thu, 8 Jul 2021 12:43:07 +0200 From: Jan Kara To: Gabriel Krisman Bertazi Cc: amir73il@gmail.com, djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, jack@suse.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v3 07/15] fsnotify: pass arguments of fsnotify() in struct fsnotify_event_info Message-ID: <20210708104307.GA1656@quack2.suse.cz> References: <20210629191035.681913-1-krisman@collabora.com> <20210629191035.681913-8-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210629191035.681913-8-krisman@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 29-06-21 15:10:27, Gabriel Krisman Bertazi wrote: > From: Amir Goldstein > > There are a lot of arguments to fsnotify() and the handle_event() method. > Pass them in a const struct instead of on the argument list. > > Apart from being more tidy, this helps with passing error reports to the > backend. __fsnotify_parent() argument list was intentionally left > untouched, because its argument list is still short enough and because > most of the event info arguments are initialized inside > __fsnotify_parent(). > > Signed-off-by: Amir Goldstein > Signed-off-by: Gabriel Krisman Bertazi > --- > fs/notify/fanotify/fanotify.c | 59 +++++++++++------------ > fs/notify/fsnotify.c | 83 +++++++++++++++++--------------- > include/linux/fsnotify.h | 15 ++++-- > include/linux/fsnotify_backend.h | 73 +++++++++++++++++++++------- > 4 files changed, 140 insertions(+), 90 deletions(-) Besides the noop function issue Amir has already pointed out I have just a few nits: > @@ -229,7 +229,11 @@ int __fsnotify_parent(struct dentry *dentry, __u32 mask, const void *data, > } > > notify: > - ret = fsnotify(mask, data, data_type, p_inode, file_name, inode, 0); > + ret = __fsnotify(mask, &(struct fsnotify_event_info) { > + .data = data, .data_type = data_type, > + .dir = p_inode, .name = file_name, > + .inode = inode, > + }); What's the advantage of using __fsnotify() here instead of fsnotify()? In terms of readability the fewer places with these initializers the better I'd say... > static int fsnotify_handle_event(struct fsnotify_group *group, __u32 mask, > - const void *data, int data_type, > - struct inode *dir, const struct qstr *name, > - u32 cookie, struct fsnotify_iter_info *iter_info) > + const struct fsnotify_event_info *event_info, > + struct fsnotify_iter_info *iter_info) > { > struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info); > struct fsnotify_mark *parent_mark = fsnotify_iter_parent_mark(iter_info); > + struct fsnotify_event_info child_event_info = { }; > int ret; No need to init child_event_info. It is fully rewritten if it gets used... > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > index f8acddcf54fb..8c2c681b4495 100644 > --- a/include/linux/fsnotify.h > +++ b/include/linux/fsnotify.h > @@ -30,7 +30,10 @@ static inline void fsnotify_name(struct inode *dir, __u32 mask, > struct inode *child, > const struct qstr *name, u32 cookie) > { > - fsnotify(mask, child, FSNOTIFY_EVENT_INODE, dir, name, NULL, cookie); > + __fsnotify(mask, &(struct fsnotify_event_info) { > + .data = child, .data_type = FSNOTIFY_EVENT_INODE, > + .dir = dir, .name = name, .cookie = cookie, > + }); > } Hmm, maybe we could have a macro initializer like: #define FSNOTIFY_EVENT_INFO(data, data_type, dir, name, inode, cookie) \ (struct fsnotify_event_info) { \ .data = (data), .data_type = (data_type), .dir = (dir), \ .name = (name), .inode = (inode), .cookie = (cookie)} Then we'd have: __fsnotify(mask, &FSNOTIFY_EVENT_INFO(child, FSNOTIFY_EVENT_INODE, dir, name, NULL, cookie)); Which looks a bit nicer to me. What do you think guys? Honza -- Jan Kara SUSE Labs, CR