[PATCH 16/22] udf: Push i_data_sem locking into udf_extend_file()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Push i_data_sem locking into udf_extend_file(). It somewhat simplifies
the code around it.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 fs/udf/inode.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index b13c35335dd1..3ffeb5651689 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -555,6 +555,7 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)
 	else
 		BUG();
 
+	down_write(&iinfo->i_data_sem);
 	/*
 	 * When creating hole in file, just don't bother with preserving
 	 * preallocation. It likely won't be very useful anyway.
@@ -599,6 +600,7 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)
 	err = 0;
 out:
 	brelse(epos.bh);
+	up_write(&iinfo->i_data_sem);
 	return err;
 }
 
@@ -1160,20 +1162,17 @@ int udf_setsize(struct inode *inode, loff_t newsize)
 			    (udf_file_entry_alloc_offset(inode) + newsize)) {
 				down_write(&iinfo->i_data_sem);
 				iinfo->i_lenAlloc = newsize;
+				up_write(&iinfo->i_data_sem);
 				goto set_size;
 			}
 			err = udf_expand_file_adinicb(inode);
 			if (err)
 				return err;
 		}
-		down_write(&iinfo->i_data_sem);
 		err = udf_extend_file(inode, newsize);
-		if (err) {
-			up_write(&iinfo->i_data_sem);
+		if (err)
 			return err;
-		}
 set_size:
-		up_write(&iinfo->i_data_sem);
 		truncate_setsize(inode, newsize);
 	} else {
 		if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
-- 
2.35.3




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux