From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Miklos Szeredi <miklos@szeredi.hu>,
Paul Moore <paul@paul-moore.com>
Subject: Re: [PATCH 12/33] fsnotify: Move locking into fsnotify_find_mark()
Date: Thu, 16 Mar 2017 09:54:14 +0100 [thread overview]
Message-ID: <20170316085414.GP12989@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxijp5yXrTQ1KR-c0FGEKuQijt+Tu=JTtsSr=oOxC0yd=A@mail.gmail.com>
On Thu 16-03-17 10:41:09, Amir Goldstein wrote:
> On Thu, Mar 16, 2017 at 10:24 AM, Jan Kara <jack@suse.cz> wrote:
> > On Wed 15-03-17 22:08:00, Amir Goldstein wrote:
> >> On Wed, Mar 15, 2017 at 12:46 PM, Jan Kara <jack@suse.cz> wrote:
> >> > Move locking of a mark list into fsnotify_find_mark(). This reduces code
> >> > churn in the following patch changing lock protecting the list.
> >> >
> >> > Signed-off-by: Jan Kara <jack@suse.cz>
> >> > ---
> >> > fs/notify/inode_mark.c | 8 +-------
> >> > fs/notify/mark.c | 8 ++++++++
> >> > fs/notify/vfsmount_mark.c | 7 +------
> >> > 3 files changed, 10 insertions(+), 13 deletions(-)
> >> >
> >> > diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
> >> > index 9b2f4e6eb8eb..f05fc49b8242 100644
> >> > --- a/fs/notify/inode_mark.c
> >> > +++ b/fs/notify/inode_mark.c
> >> > @@ -71,13 +71,7 @@ void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
> >> > struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group,
> >> > struct inode *inode)
> >> > {
> >> > - struct fsnotify_mark *mark;
> >> > -
> >> > - spin_lock(&inode->i_lock);
> >> > - mark = fsnotify_find_mark(inode->i_fsnotify_marks, group);
> >> > - spin_unlock(&inode->i_lock);
> >> > -
> >> > - return mark;
> >> > + return fsnotify_find_mark(inode->i_fsnotify_marks, group);
> >> > }
> >> >
> >> > /**
> >> > diff --git a/fs/notify/mark.c b/fs/notify/mark.c
> >> > index e7929539203a..1113dd8b2f82 100644
> >> > --- a/fs/notify/mark.c
> >> > +++ b/fs/notify/mark.c
> >> > @@ -478,16 +478,24 @@ struct fsnotify_mark *fsnotify_find_mark(struct fsnotify_mark_connector *conn,
> >> > struct fsnotify_group *group)
> >> > {
> >> > struct fsnotify_mark *mark;
> >> > + spinlock_t *lock;
> >> >
> >> > if (!conn)
> >> > return NULL;
> >> >
> >> > + if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
> >> > + lock = &conn->inode->i_lock;
> >> > + else
> >> > + lock = &conn->mnt->mnt_root->d_lock;
> >> > + spin_lock(lock);
> >>
> >> This is becoming a repeating pattern.
> >> Perhaps:
> >>
> >> lock = fsnotify_object_lock(conn);
> >
> > Yes, but it will all go away in couple of patches so I don't think it's
> > worth the churn in the patch series...
> >
>
> All I am saying is it would have been better if we had a better
> abstraction of the "object" interface.
> Since we are not going to base a new base struct for inode and vfsmount,
> the next best thing is to have wrapper macros to access the lock
> and the connector instead of open coding the type flag test everywhere
> it is needed.
>
> But if you are saying that the object lock is going to referred to rarely,
> then I see your point, but then again, it doesn't hurt to have an
> inline wrapper.
The object lock is accessed exactly 0-times after "fsnotify: Lock object
list with connector lock" in the series which is why I find the wrapper
pointless...
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2017-03-16 8:54 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 10:45 [PATCH 0/33 v5] fsnotify: Avoid SRCU stalls with fanotify permission events Jan Kara
2017-03-15 10:46 ` [PATCH 01/33] fsnotify: Remove unnecessary tests when showing fdinfo Jan Kara
2017-03-15 10:46 ` [PATCH 02/33] inotify: Remove inode pointers from debug messages Jan Kara
2017-03-15 10:46 ` [PATCH 03/33] fanotify: Move recalculation of inode / vfsmount mask under mark_mutex Jan Kara
2017-03-15 10:46 ` [PATCH 04/33] audit: Abstract hash key handling Jan Kara
2017-03-15 10:46 ` [PATCH 05/33] fsnotify: Update comments Jan Kara
2017-03-15 10:46 ` [PATCH 06/33] fsnotify: Move mark list head from object into dedicated structure Jan Kara
2017-03-15 14:11 ` Amir Goldstein
2017-03-16 7:26 ` Jan Kara
2017-03-16 7:45 ` Jan Kara
2017-03-16 8:34 ` Amir Goldstein
2017-03-16 15:50 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 07/33] fsnotify: Move object pointer to fsnotify_mark_connector Jan Kara
2017-03-15 15:00 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 08/33] fsnotify: Make fsnotify_mark_connector hold inode reference Jan Kara
2017-03-15 19:35 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 09/33] fsnotify: Remove indirection from mark list addition Jan Kara
2017-03-15 19:19 ` Amir Goldstein
2017-03-16 7:58 ` Jan Kara
2017-03-16 15:52 ` Amir Goldstein
2017-03-19 18:08 ` Jan Kara
2017-03-15 10:46 ` [PATCH 10/33] fsnotify: Move fsnotify_destroy_marks() Jan Kara
2017-03-15 10:46 ` [PATCH 11/33] fsnotify: Move locking into fsnotify_recalc_mask() Jan Kara
2017-03-15 20:03 ` Amir Goldstein
2017-03-16 8:10 ` Jan Kara
2017-03-16 10:11 ` Jan Kara
2017-03-16 15:44 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 12/33] fsnotify: Move locking into fsnotify_find_mark() Jan Kara
2017-03-15 20:08 ` Amir Goldstein
2017-03-16 8:24 ` Jan Kara
2017-03-16 8:41 ` Amir Goldstein
2017-03-16 8:54 ` Jan Kara [this message]
2017-03-16 9:21 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 13/33] fsnotify: Determine lock in fsnotify_destroy_marks() Jan Kara
2017-03-15 20:11 ` Amir Goldstein
2017-03-16 9:21 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 14/33] fsnotify: Remove indirection from fsnotify_detach_mark() Jan Kara
2017-03-15 20:18 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 15/33] fsnotify: Remove useless list deletion and comment Jan Kara
2017-03-15 20:23 ` Amir Goldstein
2017-03-15 10:46 ` [PATCH 16/33] fsnotify: Lock object list with connector lock Jan Kara
2017-03-15 10:46 ` [PATCH 17/33] fsnotify: Free fsnotify_mark_connector when there is no mark attached Jan Kara
2017-03-15 10:46 ` [PATCH 18/33] inotify: Do not drop mark reference under idr_lock Jan Kara
2017-03-15 10:46 ` [PATCH 19/33] fsnotify: Move queueing of mark for destruction into fsnotify_put_mark() Jan Kara
2017-03-15 10:46 ` [PATCH 20/33] fsnotify: Detach mark from object list when last reference is dropped Jan Kara
2017-03-15 10:46 ` [PATCH 21/33] fsnotify: Remove special handling of mark destruction on group shutdown Jan Kara
2017-03-15 10:46 ` [PATCH 22/33] fsnotify: Provide framework for dropping SRCU lock in ->handle_event Jan Kara
2017-03-15 10:46 ` [PATCH 23/33] fsnotify: Pass fsnotify_iter_info into handle_event handler Jan Kara
2017-03-15 10:46 ` [PATCH 24/33] fanotify: Release SRCU lock when waiting for userspace response Jan Kara
2017-03-15 10:46 ` [PATCH 25/33] fsnotify: Remove fsnotify_set_mark_{,ignored_}mask_locked() Jan Kara
2017-03-15 10:46 ` [PATCH 26/33] fsnotify: Remove fsnotify_recalc_{inode|vfsmount}_mask() Jan Kara
2017-03-15 10:46 ` [PATCH 27/33] fsnotify: Inline fsnotify_clear_{inode|vfsmount}_mark_group() Jan Kara
2017-03-15 10:46 ` [PATCH 28/33] fsnotify: Rename fsnotify_clear_marks_by_group_flags() Jan Kara
2017-03-15 10:46 ` [PATCH 29/33] fsnotify: Remove fsnotify_detach_group_marks() Jan Kara
2017-03-15 10:46 ` [PATCH 30/33] fsnotify: Remove fsnotify_find_{inode|vfsmount}_mark() Jan Kara
2017-03-15 10:46 ` [PATCH 31/33] fsnotify: Drop inode_mark.c Jan Kara
2017-03-15 10:46 ` [PATCH 32/33] fsnotify: Add group pointer in fsnotify_init_mark() Jan Kara
2017-03-15 10:46 ` [PATCH 33/33] fsnotify: Move ->free_mark callback to fsnotify_ops Jan Kara
-- strict thread matches above, loose matches on Subject: below --
2017-03-28 16:12 [PATCH 0/33 v6] fsnotify: Avoid SRCU stalls with fanotify permission events Jan Kara
2017-03-28 16:13 ` [PATCH 12/33] fsnotify: Move locking into fsnotify_find_mark() Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170316085414.GP12989@quack2.suse.cz \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=paul@paul-moore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).