[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101102004545.GQ2715@dastard>
Date: Tue, 2 Nov 2010 11:45:45 +1100
From: Dave Chinner <david@...morbit.com>
To: Mimi Zohar <zohar@...ux.vnet.ibm.com>
Cc: linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org,
linux-fsdevel@...r.kernel.org, jmorris@...ei.org,
akpm@...ux-foundation.org, torvalds@...ux-foundation.org,
eparis@...hat.com, viro@...iv.linux.org.uk,
Mimi Zohar <zohar@...ibm.com>
Subject: Re: [PATCH v1.1 2/5] IMA: define readcount functions
On Mon, Nov 01, 2010 at 03:45:36PM -0400, Mimi Zohar wrote:
> Define iget/iput_readcount() functions to be called from the VFS layer.
Can't say I like the function names. i_readcount_{inc,dec} seem more
appropriate, especially so they don't get confused with inode
reference counting...
Cheers,
Dave.
> +void iput_readcount(struct inode *inode)
> +{
> + spin_lock(&inode->i_lock);
> + if (unlikely((atomic_read(&inode->i_readcount) == 0)))
> + printk(KERN_INFO "i_readcount: imbalance ino %ld\n",
> + inode->i_ino);
> + else
> + atomic_dec(&inode->i_readcount);
> + spin_unlock(&inode->i_lock);
> +}
No need for the lock just to indicate an imbalance. You could just
use:
if (atomic_dec_return(&inode->i_readcount) < 0) {
.....
}
Given this is an integrity subsystem, I suspect the correct thing to
do here is BUG(), not just issue an informational message that
something is wrong with the integrity tracking....
Cheers,
Dave.
--
Dave Chinner
david@...morbit.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists