Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1778476ybc; Wed, 20 Nov 2019 04:03:53 -0800 (PST) X-Google-Smtp-Source: APXvYqy05GT3FqdwDmJriCkmwtx2fqJviYX9F0gvonUUYP0fuW2+jeAsJjFxfV0mXwVC3HBxke9N X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr5000473ejw.286.1574251432924; Wed, 20 Nov 2019 04:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574251432; cv=none; d=google.com; s=arc-20160816; b=ZVW+a38A0uXXPhhZMwEA1GgfYBZFQeW/BbU4cuPxmNFHC6nT4kbDvqHfx59PTwnZns ts9JqTsKLgBa67jJp4Hy1a8JkNG8aSkdorMlBKzpzrV9aK2Wfy4bPiS3rvx+bI8s9nKQ XAn1rXhl9GC87VKTZhMIPEUca49XSLUEP9M0AWZz+IcDFKWNFLzLbNbx5a2q2CB6ASP5 /zJYSojayDgTDb/J63SXgKnWYyQ+yVCZqny2rB7i2Fxs6D4ZvT8w36dR/GSVuGk/ILcg 6zKzUk/6kDB1jam38W1Ls/lQrnFFd0ko4VgQraLBNuH15XsU2Pf/HsG6QY/hQq8fi/WU 3MNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I2Xo/a4CE3Y8LwPp0U+2KlzLXKiFkdTHaNAt0710fdc=; b=qF9dqaGs07U21/J4/EWjCf+B3rtCI8HqdMI7iQmsSJanSOc6ZQJWUUklnx5QnjhFz7 3naaQAAIY6lp9ZcQepmmfvhOB/7AQZlYxAcsq9ebCYRJO3prmCROgDvQ7s3sM84Zl5eb BDN0odVptyOMuhcOzZdD16UUZOzPVJ/q5+EJjBCmGzbM7hV973o3euJPEAeqwauAnc2R 38IZwo+7F0yJM+gSQ/YEES33LfA+3NmAmgT9rTX+M0JdegLdA6s1DhMfwa5pi6KkmN8k lXRBM4T7nWWEE5ndvrrNW+iZja/7l7ObZQvyJitJ1pPIpkA7GYxKf55v/sC0DkRz85ja 7Bsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b="l/kP8sv8"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si18079518eju.333.2019.11.20.04.03.22; Wed, 20 Nov 2019 04:03:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b="l/kP8sv8"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729154AbfKTLXs (ORCPT + 99 others); Wed, 20 Nov 2019 06:23:48 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:34710 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728376AbfKTLXs (ORCPT ); Wed, 20 Nov 2019 06:23:48 -0500 Received: by mail-pj1-f66.google.com with SMTP id bo14so3985719pjb.1 for ; Wed, 20 Nov 2019 03:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=I2Xo/a4CE3Y8LwPp0U+2KlzLXKiFkdTHaNAt0710fdc=; b=l/kP8sv8rbBonNJD5hfKwtBrBCw261ACJMV1fHVcQI6eYOt80p4FGOcVz4f9hcnqt6 OznLYjU7zaT84MGfk6rlbz4Ri0l4NKpU48k/ejqZ3GbZq2Oq7IVfPNSnIRSnMxI9L/Hf JiGF0x/3sof5R4YkndvPZCO36yesES8MGjAv7O4IfUt2spkEHJ8iG7zcqrYqx9oijjdf QGX0Bhc6Sg8sD7B93/+xNoLH7HuV8HWhG01k8ZVhZOI4weyk1l3VCHzolQ5zcu4J6cP/ 0P8CBYnr0fzdo5BPILwAd3tpoInZImFoOwBuK3CDUmsC/FrOecrpjjxYSjX8dnwSD2I/ Fv2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=I2Xo/a4CE3Y8LwPp0U+2KlzLXKiFkdTHaNAt0710fdc=; b=nQE614Jmdp5QWDkRtgpLucQONaaKszjdz47+9HP5h2e4FeqP7lMyPbiV0+Qd8URj9J 961MYCywi8jA9jtp0DH8y8kFZDIDQ/j5Zd0cPUDI0F0CKwA8ihKqHnmOw53mk06TLM0v 5CNx+/NBbdmQiXdPFi6NX02kud8EZ33LGBHeub4TFJRLexiRNtXXOBkSVW6BtmPuFxMC 6Yqh1n/vItKiYaTMQ2FpOs3LX+Kil9hoeq2sdy41XJIc93OisYisV/GA2j9ZtdRkcbwk GH+UyciwqCQkQGUgD+tUBZSdPktjoQvAgt8kFtMmtIcXvvcCLJKqb+novYLvwh8My2v1 EAsg== X-Gm-Message-State: APjAAAUuAKb9P81bQQFlqZj/D9t/YSFg6ID4L8eKuUEjQPppa2JDINQj EU6Ho51j4Lc5oGybVd9qbLuM/ye6iw== X-Received: by 2002:a17:90b:908:: with SMTP id bo8mr3493332pjb.1.1574249027381; Wed, 20 Nov 2019 03:23:47 -0800 (PST) Received: from bobrowski ([110.232.114.101]) by smtp.gmail.com with ESMTPSA id j4sm7144530pjf.25.2019.11.20.03.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 03:23:46 -0800 (PST) Date: Wed, 20 Nov 2019 22:23:40 +1100 From: Matthew Bobrowski To: Ritesh Harjani Cc: jack@suse.cz, tytso@mit.edu, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFCv3 2/4] ext4: Add ext4_ilock & ext4_iunlock API Message-ID: <20191120112339.GB30486@bobrowski> References: <20191120050024.11161-1-riteshh@linux.ibm.com> <20191120050024.11161-3-riteshh@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191120050024.11161-3-riteshh@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Nov 20, 2019 at 10:30:22AM +0530, Ritesh Harjani wrote: > This adds ext4_ilock/iunlock types of APIs. > This is the preparation APIs to make shared > locking/unlocking & restarting with exclusive > locking/unlocking easier in next patch. *scratches head* A nit, but what's with the changelog wrapping at like ~40 characters? > +#define EXT4_IOLOCK_EXCL (1 << 0) > +#define EXT4_IOLOCK_SHARED (1 << 1) > > +static inline void ext4_ilock(struct inode *inode, unsigned int iolock) > +{ > + if (iolock == EXT4_IOLOCK_EXCL) > + inode_lock(inode); > + else > + inode_lock_shared(inode); > +} > + > +static inline void ext4_iunlock(struct inode *inode, unsigned int iolock) > +{ > + if (iolock == EXT4_IOLOCK_EXCL) > + inode_unlock(inode); > + else > + inode_unlock_shared(inode); > +} > + > +static inline int ext4_ilock_nowait(struct inode *inode, unsigned int iolock) > +{ > + if (iolock == EXT4_IOLOCK_EXCL) > + return inode_trylock(inode); > + else > + return inode_trylock_shared(inode); > +} Is it really necessary for all these helpers to actually have the 'else' statement? Could we not just return/set whatever takes the 'else' branch directly from the end of these functions? I think it would be cleaner that way. /me doesn't really like the naming of these functions either. What's people's opinion on changing these for example: - ext4_inode_lock() - ext4_inode_unlock() Or, better yet, is there any reason why we've never actually considered naming such functions to have the verb precede the actual object that we're performing the operation on? In my opinion, it totally makes way more sense from a code readability standpoint and overall intent of the function. For example: - ext4_lock_inode() - ext4_unlock_inode() > +static inline void ext4_ilock_demote(struct inode *inode, unsigned int iolock) > +{ > + BUG_ON(iolock != EXT4_IOLOCK_EXCL); > + downgrade_write(&inode->i_rwsem); > +} > + Same principle would also apply here. On an ending note, I'm not really sure that I like the name of these macros. Like, for example, expand the macro 'EXT4_IOLOCK_EXCL' into plain english words as if you were reading it. This would translate to something like 'EXT4 INPUT/OUPUT LOCK EXCLUSIVE' or 'EXT4 IO LOCK EXCLUSIVE'. Just flipping the words around make a significant improvement for overall readability i.e. 'EXT4_EXCL_IOLOCK', which would expand out to 'EXT4 EXCLUSIVE IO LOCK'. Speaking of, is there any reason why we don't mention 'INODE' here seeing as though that's the object we're actually protecting by taking one of these locking mechanisms? /M