From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com ([209.85.167.67]:41450 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbeG0GHT (ORCPT ); Fri, 27 Jul 2018 02:07:19 -0400 Received: by mail-lf1-f67.google.com with SMTP id v22-v6so2666159lfe.8 for ; Thu, 26 Jul 2018 21:47:17 -0700 (PDT) MIME-Version: 1.0 References: <20180710100217.12866-1-jack@suse.cz> <20180710100217.12866-2-jack@suse.cz> In-Reply-To: <20180710100217.12866-2-jack@suse.cz> From: Paul Moore Date: Fri, 27 Jul 2018 00:47:04 -0400 Message-ID: Subject: Re: [PATCH 01/10] audit_tree: Remove mark->lock locking To: jack@suse.cz Cc: linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, rgb@redhat.com, amir73il@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Jul 10, 2018 at 6:02 AM Jan Kara wrote: > Currently, audit_tree code uses mark->lock to protect against detaching > of mark from an inode. In most places it however also uses > mark->group->mark_mutex (as we need to atomically replace attached > marks) and this provides protection against mark detaching as well. So > just remove protection with mark->lock from audit tree code and replace > it with mark->group->mark_mutex protection in all the places. It > simplifies the code and gets rid of some ugly catches like calling > fsnotify_add_mark_locked() with mark->lock held (which cannot sleep only > because we hold a reference to another mark attached to the same inode). > > Signed-off-by: Jan Kara > --- > kernel/audit_tree.c | 24 ++++-------------------- > 1 file changed, 4 insertions(+), 20 deletions(-) ... > diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c > index 02feef939560..1c82eb6674c4 100644 > --- a/kernel/audit_tree.c > +++ b/kernel/audit_tree.c > @@ -360,12 +355,12 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree) > return -ENOSPC; > } > > - spin_lock(&entry->lock); > + mutex_lock(&entry->group->mark_mutex); I wonder if we could move the lock up above the fsnotify_add_inode_mark() earlier in create_chunk() and use fsnotify_add_mark_locked()? -- paul moore www.paul-moore.com