[PATCH 09/11] xfs: use xfs_ilock_attr_map_shared in xfs_attr_get

Christoph Hellwig
2013-12-06T20:31:30Z

[-- Attachment #1: xfs-attr-locking --]
[-- Type: text/plain, Size: 946 bytes --]

We might not have read in the extent list at this point, so make sure we
take the ilock exclusively if we have to do so.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: xfs/fs/xfs/xfs_attr.c
===================================================================
--- xfs.orig/fs/xfs/xfs_attr.c 2013-12-06 17:20:27.447331601 +0100
+++ xfs/fs/xfs/xfs_attr.c 2013-12-06 19:41:05.119158446 +0100
@@ -164,6 +164,7 @@ xfs_attr_get(
{
int error;
struct xfs_name xname;
+ uint lock_mode;

XFS_STATS_INC(xs_attr_get);

@@ -174,9 +175,9 @@ xfs_attr_get(
if (error)
return error;

- xfs_ilock(ip, XFS_ILOCK_SHARED);
+ lock_mode = xfs_ilock_attr_map_shared(ip);
error = xfs_attr_get_int(ip, &xname, value, valuelenp, flags);
- xfs_iunlock(ip, XFS_ILOCK_SHARED);
+ xfs_iunlock(ip, lock_mode);
return(error);
}