Return-Path: Received: from mx2.suse.de ([195.135.220.15]:40479 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751895AbdCPKLx (ORCPT ); Thu, 16 Mar 2017 06:11:53 -0400 Date: Thu, 16 Mar 2017 11:11:44 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , linux-fsdevel , Miklos Szeredi , Paul Moore Subject: Re: [PATCH 11/33] fsnotify: Move locking into fsnotify_recalc_mask() Message-ID: <20170316101144.GQ12989@quack2.suse.cz> References: <20170315104632.7037-1-jack@suse.cz> <20170315104632.7037-12-jack@suse.cz> <20170316081056.GM12989@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170316081056.GM12989@quack2.suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu 16-03-17 09:10:56, Jan Kara wrote: > > > + new_mask |= mark->mask; > > > + } > > > + if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) > > > + conn->inode->i_fsnotify_mask = new_mask; > > > + else if (conn->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT) > > > + real_mount(conn->mnt)->mnt_fsnotify_mask = new_mask; > > > +} > > > + > > > +/* > > > + * Calculate mask of events for a list of marks. The caller must make sure list > > > + * cannot disappear under us (usually by holding a mark->lock or > > > + * mark->group->mark_mutex for a mark on this list). > > > + */ > > > +void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn) > > > +{ > > > if (!conn) > > > - return 0; > > > + return; > > > + > > > + if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) > > > + spin_lock(&conn->inode->i_lock); > > > + else > > > + spin_lock(&conn->mnt->mnt_root->d_lock); > > > + __fsnotify_recalc_mask(conn); > > > + if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) { > > > + struct inode *inode = igrab(conn->inode); > > > > > > > igrab change here related to this patch or belongs to future patch? > > If belongs here, better drop a word about it in commit message. > > It is making fsnotify_recalc_mask() more self-contained - with igrab() > it does not have to assume the caller has somehow pinned the inode. As such > it is not directly related to this locking change so I'll move it to a > separate commit with appropriate message. In the end, I've decided to just completely drop this change (as I've verified no caller really needs it) and added a comment explaining how callers must make sure inode is not going away under us. Honza -- Jan Kara SUSE Labs, CR