From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH 19/24] Unionfs: Helper macros/inlines Date: Mon, 8 Jan 2007 13:28:17 -0800 Message-ID: <20070108132817.5c9a30d6.akpm@osdl.org> References: <1168229596580-git-send-email-jsipek@cs.sunysb.edu> <11682295994056-git-send-email-jsipek@cs.sunysb.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, viro@ftp.linux.org.uk, torvalds@osdl.org, mhalcrow@us.ibm.com, David Quigley , Erez Zadok Return-path: Received: from smtp.osdl.org ([65.172.181.24]:44813 "EHLO smtp.osdl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbXAHV3I (ORCPT ); Mon, 8 Jan 2007 16:29:08 -0500 To: "Josef 'Jeff' Sipek" In-Reply-To: <11682295994056-git-send-email-jsipek@cs.sunysb.edu> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, 7 Jan 2007 23:13:11 -0500 "Josef 'Jeff' Sipek" wrote: > From: Josef "Jeff" Sipek > > This patch contains many macros and inline functions used thoughout Unionfs. > > .. > > +#define ibstart(ino) (UNIONFS_I(ino)->bstart) > +#define ibend(ino) (UNIONFS_I(ino)->bend) > + > +/* Superblock to private data */ > +#define UNIONFS_SB(super) ((struct unionfs_sb_info *)(super)->s_fs_info) > +#define sbstart(sb) 0 > +#define sbend(sb) (UNIONFS_SB(sb)->bend) > +#define sbmax(sb) (UNIONFS_SB(sb)->bend + 1) > + > +/* File to private Data */ > +#define UNIONFS_F(file) ((struct unionfs_file_info *)((file)->private_data)) > +#define fbstart(file) (UNIONFS_F(file)->bstart) > +#define fbend(file) (UNIONFS_F(file)->bend) > > ... > > +#define dbstart(dent) (UNIONFS_D(dent)->bstart) > +#define set_dbstart(dent, val) do { UNIONFS_D(dent)->bstart = val; } while(0) > +#define dbend(dent) (UNIONFS_D(dent)->bend) > +#define set_dbend(dent, val) do { UNIONFS_D(dent)->bend = val; } while(0) > +#define dbopaque(dent) (UNIONFS_D(dent)->bopaque) > +#define set_dbopaque(dent, val) do { UNIONFS_D(dent)->bopaque = val; } while (0) Please prefer to use inlined C fucntions. Macros should only be used if there is some reason why an inlined fucntion will not work. > +#define lock_dentry(d) down(&UNIONFS_D(d)->sem) > +#define unlock_dentry(d) up(&UNIONFS_D(d)->sem) > +#define verify_locked(d) Ditto. Please use mutexes where possible. Semaphores should only be used when their counting feature is employed. And, arguably, in situations where a lock is locked and unlocked from different threads, because this presently triggers mutex debugging warnings, although we should find a way of fixing this in the mutex code. I can't say I like the name "lock_dentry" much. It sounds like a VFS function and we may well gain a generic lock_dentry() at some time in the future. unionfs_lock_dentry() would be a better choice.