]> git.hungrycats.org Git - linux/commit
[PATCH] Missing brelse() in ext2/ext3 extended attribute code
authorAndrew Morton <akpm@digeo.com>
Wed, 9 Apr 2003 04:31:28 +0000 (21:31 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Wed, 9 Apr 2003 04:31:28 +0000 (21:31 -0700)
commit72c4f88a9d99432b1e3645d8ddccd17089a670c3
treeeb8468879b6056eac0c324cd1c671b04387313d0
parent92a88ec99e1ecd5f1fc2f77d039e61fca6ec382e
[PATCH] Missing brelse() in ext2/ext3 extended attribute code

From: Andreas Gruenbacher <agruen@suse.de>

Missing brelse() in ext2/ext3 extended attribute code

The ext2 and ext3 EA implementations fail to release a buffer_head if
the inode that is being accessed is sharing EAs with another inode, and
an attribute is set to the same value that it has already, like so:

        $ touch f g
$ setfattr -n user.test -v test f g
# (Now, both f and g refer to the same EA block.)
$ setfattr -n user.test -v test f

With the bug, an "invalidate: busy buffer" or "invalidate: dirty
buffer" message will be logged when the file system is unmounted. This
patch fixes the problem.

At the implementation level:

The code was assuming that ext3_xattr_cache_find cannot return the same
block the inode already is associated with, so testing for (old_bh !=
new_bh) would determine whether the old block is resued or an additional
bh is held. This is wrong if the EA block is used by multiple inodes (in
which case it stays in the cache), and the block isn't actually
modified.  Instead of testing for (old_bh != new_bh), the code now does
a get_bh() in the branch that keeps the old block, which assures that
new_bh now is either NULL or a handle that must be released at the end
of ext3_xattr_set_handle2().
fs/ext2/xattr.c
fs/ext3/xattr.c