xfs: add xfs_ilock_attr_map_shared
[deliverable/linux.git] / fs / xfs / xfs_bmap_util.c
index 5887e41c0323ae85f867cc9bc83bbdf8c1e41cd1..374ba050942f596a1b282a9fa209b4a7bf67f375 100644 (file)
@@ -617,22 +617,27 @@ xfs_getbmap(
                return XFS_ERROR(ENOMEM);
 
        xfs_ilock(ip, XFS_IOLOCK_SHARED);
-       if (whichfork == XFS_DATA_FORK && !(iflags & BMV_IF_DELALLOC)) {
-               if (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size) {
+       if (whichfork == XFS_DATA_FORK) {
+               if (!(iflags & BMV_IF_DELALLOC) &&
+                   (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
                        error = -filemap_write_and_wait(VFS_I(ip)->i_mapping);
                        if (error)
                                goto out_unlock_iolock;
+
+                       /*
+                        * Even after flushing the inode, there can still be
+                        * delalloc blocks on the inode beyond EOF due to
+                        * speculative preallocation.  These are not removed
+                        * until the release function is called or the inode
+                        * is inactivated.  Hence we cannot assert here that
+                        * ip->i_delayed_blks == 0.
+                        */
                }
-               /*
-                * even after flushing the inode, there can still be delalloc
-                * blocks on the inode beyond EOF due to speculative
-                * preallocation. These are not removed until the release
-                * function is called or the inode is inactivated. Hence we
-                * cannot assert here that ip->i_delayed_blks == 0.
-                */
-       }
 
-       lock = xfs_ilock_map_shared(ip);
+               lock = xfs_ilock_data_map_shared(ip);
+       } else {
+               lock = xfs_ilock_attr_map_shared(ip);
+       }
 
        /*
         * Don't let nex be bigger than the number of extents
@@ -737,7 +742,7 @@ xfs_getbmap(
  out_free_map:
        kmem_free(map);
  out_unlock_ilock:
-       xfs_iunlock_map_shared(ip, lock);
+       xfs_iunlock(ip, lock);
  out_unlock_iolock:
        xfs_iunlock(ip, XFS_IOLOCK_SHARED);
 
This page took 0.027146 seconds and 5 git commands to generate.