Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754001Ab3JDB2H (ORCPT ); Thu, 3 Oct 2013 21:28:07 -0400 Received: from g4t0014.houston.hp.com ([15.201.24.17]:49046 "EHLO g4t0014.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752898Ab3JDB2G (ORCPT ); Thu, 3 Oct 2013 21:28:06 -0400 Message-ID: <1380850082.2280.18.camel@buesod1.americas.hpqcorp.net> Subject: Re: [PATCH 1/2] mm,fs: introduce helpers around i_mmap_mutex From: Davidlohr Bueso To: Andrew Morton Cc: Ingo Molnar , Peter Zijlstra , aswin@hp.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Date: Thu, 03 Oct 2013 18:28:02 -0700 In-Reply-To: <1380834035.2280.5.camel@buesod1.americas.hpqcorp.net> References: <1380745066-9925-1-git-send-email-davidlohr@hp.com> <1380745066-9925-2-git-send-email-davidlohr@hp.com> <20131003135822.e0b2ca10fe5a460714bb82a3@linux-foundation.org> <1380834035.2280.5.camel@buesod1.americas.hpqcorp.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.6.4 (3.6.4-3.fc18) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2888 Lines: 87 On Thu, 2013-10-03 at 14:00 -0700, Davidlohr Bueso wrote: > On Thu, 2013-10-03 at 13:58 -0700, Andrew Morton wrote: > > On Wed, 2 Oct 2013 13:17:45 -0700 Davidlohr Bueso wrote: > > > > > Various parts of the kernel acquire and release this mutex, > > > so add i_mmap_lock_write() and immap_unlock_write() helper > > > functions that will encapsulate this logic. The next patch > > > will make use of these. > > > > > > ... > > > > > > --- a/include/linux/fs.h > > > +++ b/include/linux/fs.h > > > @@ -478,6 +478,16 @@ struct block_device { > > > > > > int mapping_tagged(struct address_space *mapping, int tag); > > > > > > +static inline void i_mmap_lock_write(struct address_space *mapping) > > > +{ > > > + mutex_lock(&mapping->i_mmap_mutex); > > > +} > > > > I don't understand the thinking behind the "_write". There is no > > "_read" and all callsites use "_write", so why not call it > > i_mmap_lock()? > > > > I *assume* the answer is "so we can later convert some sites to a new > > i_mmap_lock_read()". If so, the changelog should have discussed this. > > If not, still confused. > > > > Yes, that's exactly right. I'll resend with an updated changelog. So here's an updated changelog, I left it generic enough for us not to rely on the lock type characteristics, since if/when changed, it can remain a sleeping lock (rwsem) or not, for rwlock_t. 8<----------------------------------------- From: Davidlohr Bueso Subject: [PATCH 1/2] mm,fs: introduce helpers around i_mmap_mutex Various parts of the kernel acquire and release this mutex, so add i_mmap_lock_write() and immap_unlock_write() helper functions that will encapsulate this logic. The next patch will make use of these. Note that since this lock is currently a mutex, only introduce write related functions. In the future, the lock type can be changed and reading semantics can be added such that the lock can be shared when allowed. Signed-off-by: Davidlohr Bueso --- include/linux/fs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3f40547..b32e64f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -478,6 +478,16 @@ struct block_device { int mapping_tagged(struct address_space *mapping, int tag); +static inline void i_mmap_lock_write(struct address_space *mapping) +{ + mutex_lock(&mapping->i_mmap_mutex); +} + +static inline void i_mmap_unlock_write(struct address_space *mapping) +{ + mutex_unlock(&mapping->i_mmap_mutex); +} + /* * Might pages of this file be mapped into userspace? */ -- 1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/