diff options
author | Jan Kara <jack@suse.cz> | 2023-01-19 14:28:37 +0300 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2023-01-26 18:46:34 +0300 |
commit | 6a3b37e0ea20bcb50e519c75fae3387199f35400 (patch) | |
tree | 3de82574f6f6fec59e170073f4916e8e97ac0951 /fs/udf/file.c | |
parent | f950fd0529130a617b3da526da9fb6a896ce87c2 (diff) | |
download | linux-6a3b37e0ea20bcb50e519c75fae3387199f35400.tar.xz |
udf: Push i_data_sem locking into udf_expand_file_adinicb()
The checks we do in udf_setsize() and udf_file_write_iter() are safe to
do only with i_rwsem locked as it stabilizes both file type and file
size. Hence we don't need to lock i_data_sem before we enter
udf_expand_file_adinicb() which simplifies the locking somewhat.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/file.c')
-rw-r--r-- | fs/udf/file.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c index 8be51161f3e5..60524814c594 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -148,7 +148,6 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (retval <= 0) goto out; - down_write(&iinfo->i_data_sem); if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + iocb->ki_pos + iov_iter_count(from))) { @@ -158,15 +157,15 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from) udf_debug("udf_expand_adinicb: err=%d\n", err); return err; } - } else - up_write(&iinfo->i_data_sem); + } retval = __generic_file_write_iter(iocb, from); out: - down_write(&iinfo->i_data_sem); - if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && retval > 0) + if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && retval > 0) { + down_write(&iinfo->i_data_sem); iinfo->i_lenAlloc = inode->i_size; - up_write(&iinfo->i_data_sem); + up_write(&iinfo->i_data_sem); + } inode_unlock(inode); if (retval > 0) { |