@@ -376,7 +376,7 @@ static int ext4_update_inline_data(handle_t *handle, struct inode *inode,
376
376
static int ext4_prepare_inline_data (handle_t * handle , struct inode * inode ,
377
377
unsigned int len )
378
378
{
379
- int ret , size ;
379
+ int ret , size , no_expand ;
380
380
struct ext4_inode_info * ei = EXT4_I (inode );
381
381
382
382
if (!ext4_test_inode_state (inode , EXT4_STATE_MAY_INLINE_DATA ))
@@ -386,15 +386,14 @@ static int ext4_prepare_inline_data(handle_t *handle, struct inode *inode,
386
386
if (size < len )
387
387
return - ENOSPC ;
388
388
389
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
389
+ ext4_write_lock_xattr ( inode , & no_expand );
390
390
391
391
if (ei -> i_inline_off )
392
392
ret = ext4_update_inline_data (handle , inode , len );
393
393
else
394
394
ret = ext4_create_inline_data (handle , inode , len );
395
395
396
- up_write (& EXT4_I (inode )-> xattr_sem );
397
-
396
+ ext4_write_unlock_xattr (inode , & no_expand );
398
397
return ret ;
399
398
}
400
399
@@ -523,7 +522,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
523
522
struct inode * inode ,
524
523
unsigned flags )
525
524
{
526
- int ret , needed_blocks ;
525
+ int ret , needed_blocks , no_expand ;
527
526
handle_t * handle = NULL ;
528
527
int retries = 0 , sem_held = 0 ;
529
528
struct page * page = NULL ;
@@ -563,7 +562,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
563
562
goto out ;
564
563
}
565
564
566
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
565
+ ext4_write_lock_xattr ( inode , & no_expand );
567
566
sem_held = 1 ;
568
567
/* If some one has already done this for us, just exit. */
569
568
if (!ext4_has_inline_data (inode )) {
@@ -599,7 +598,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
599
598
page_cache_release (page );
600
599
page = NULL ;
601
600
ext4_orphan_add (handle , inode );
602
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
601
+ ext4_write_unlock_xattr ( inode , & no_expand );
603
602
sem_held = 0 ;
604
603
ext4_journal_stop (handle );
605
604
handle = NULL ;
@@ -625,7 +624,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
625
624
page_cache_release (page );
626
625
}
627
626
if (sem_held )
628
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
627
+ ext4_write_unlock_xattr ( inode , & no_expand );
629
628
if (handle )
630
629
ext4_journal_stop (handle );
631
630
brelse (iloc .bh );
@@ -718,7 +717,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
718
717
int ext4_write_inline_data_end (struct inode * inode , loff_t pos , unsigned len ,
719
718
unsigned copied , struct page * page )
720
719
{
721
- int ret ;
720
+ int ret , no_expand ;
722
721
void * kaddr ;
723
722
struct ext4_iloc iloc ;
724
723
@@ -736,7 +735,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
736
735
goto out ;
737
736
}
738
737
739
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
738
+ ext4_write_lock_xattr ( inode , & no_expand );
740
739
BUG_ON (!ext4_has_inline_data (inode ));
741
740
742
741
kaddr = kmap_atomic (page );
@@ -746,7 +745,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
746
745
/* clear page dirty so that writepages wouldn't work for us. */
747
746
ClearPageDirty (page );
748
747
749
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
748
+ ext4_write_unlock_xattr ( inode , & no_expand );
750
749
brelse (iloc .bh );
751
750
out :
752
751
return copied ;
@@ -757,7 +756,7 @@ ext4_journalled_write_inline_data(struct inode *inode,
757
756
unsigned len ,
758
757
struct page * page )
759
758
{
760
- int ret ;
759
+ int ret , no_expand ;
761
760
void * kaddr ;
762
761
struct ext4_iloc iloc ;
763
762
@@ -767,11 +766,11 @@ ext4_journalled_write_inline_data(struct inode *inode,
767
766
return NULL ;
768
767
}
769
768
770
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
769
+ ext4_write_lock_xattr ( inode , & no_expand );
771
770
kaddr = kmap_atomic (page );
772
771
ext4_write_inline_data (inode , & iloc , kaddr , 0 , len );
773
772
kunmap_atomic (kaddr );
774
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
773
+ ext4_write_unlock_xattr ( inode , & no_expand );
775
774
776
775
return iloc .bh ;
777
776
}
@@ -1255,7 +1254,7 @@ static int ext4_convert_inline_data_nolock(handle_t *handle,
1255
1254
int ext4_try_add_inline_entry (handle_t * handle , struct ext4_filename * fname ,
1256
1255
struct dentry * dentry , struct inode * inode )
1257
1256
{
1258
- int ret , inline_size ;
1257
+ int ret , inline_size , no_expand ;
1259
1258
void * inline_start ;
1260
1259
struct ext4_iloc iloc ;
1261
1260
struct inode * dir = d_inode (dentry -> d_parent );
@@ -1264,7 +1263,7 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
1264
1263
if (ret )
1265
1264
return ret ;
1266
1265
1267
- down_write ( & EXT4_I ( dir ) -> xattr_sem );
1266
+ ext4_write_lock_xattr ( dir , & no_expand );
1268
1267
if (!ext4_has_inline_data (dir ))
1269
1268
goto out ;
1270
1269
@@ -1310,7 +1309,7 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
1310
1309
1311
1310
out :
1312
1311
ext4_mark_inode_dirty (handle , dir );
1313
- up_write ( & EXT4_I ( dir ) -> xattr_sem );
1312
+ ext4_write_unlock_xattr ( dir , & no_expand );
1314
1313
brelse (iloc .bh );
1315
1314
return ret ;
1316
1315
}
@@ -1670,15 +1669,15 @@ int ext4_delete_inline_entry(handle_t *handle,
1670
1669
struct buffer_head * bh ,
1671
1670
int * has_inline_data )
1672
1671
{
1673
- int err , inline_size ;
1672
+ int err , inline_size , no_expand ;
1674
1673
struct ext4_iloc iloc ;
1675
1674
void * inline_start ;
1676
1675
1677
1676
err = ext4_get_inode_loc (dir , & iloc );
1678
1677
if (err )
1679
1678
return err ;
1680
1679
1681
- down_write ( & EXT4_I ( dir ) -> xattr_sem );
1680
+ ext4_write_lock_xattr ( dir , & no_expand );
1682
1681
if (!ext4_has_inline_data (dir )) {
1683
1682
* has_inline_data = 0 ;
1684
1683
goto out ;
@@ -1713,7 +1712,7 @@ int ext4_delete_inline_entry(handle_t *handle,
1713
1712
1714
1713
ext4_show_inline_dir (dir , iloc .bh , inline_start , inline_size );
1715
1714
out :
1716
- up_write ( & EXT4_I ( dir ) -> xattr_sem );
1715
+ ext4_write_unlock_xattr ( dir , & no_expand );
1717
1716
brelse (iloc .bh );
1718
1717
if (err != - ENOENT )
1719
1718
ext4_std_error (dir -> i_sb , err );
@@ -1812,11 +1811,11 @@ int empty_inline_dir(struct inode *dir, int *has_inline_data)
1812
1811
1813
1812
int ext4_destroy_inline_data (handle_t * handle , struct inode * inode )
1814
1813
{
1815
- int ret ;
1814
+ int ret , no_expand ;
1816
1815
1817
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
1816
+ ext4_write_lock_xattr ( inode , & no_expand );
1818
1817
ret = ext4_destroy_inline_data_nolock (handle , inode );
1819
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
1818
+ ext4_write_unlock_xattr ( inode , & no_expand );
1820
1819
1821
1820
return ret ;
1822
1821
}
@@ -1901,7 +1900,7 @@ int ext4_try_to_evict_inline_data(handle_t *handle,
1901
1900
void ext4_inline_data_truncate (struct inode * inode , int * has_inline )
1902
1901
{
1903
1902
handle_t * handle ;
1904
- int inline_size , value_len , needed_blocks ;
1903
+ int inline_size , value_len , needed_blocks , no_expand ;
1905
1904
size_t i_size ;
1906
1905
void * value = NULL ;
1907
1906
struct ext4_xattr_ibody_find is = {
@@ -1918,7 +1917,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1918
1917
if (IS_ERR (handle ))
1919
1918
return ;
1920
1919
1921
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
1920
+ ext4_write_lock_xattr ( inode , & no_expand );
1922
1921
if (!ext4_has_inline_data (inode )) {
1923
1922
* has_inline = 0 ;
1924
1923
ext4_journal_stop (handle );
@@ -1976,7 +1975,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1976
1975
up_write (& EXT4_I (inode )-> i_data_sem );
1977
1976
out :
1978
1977
brelse (is .iloc .bh );
1979
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
1978
+ ext4_write_unlock_xattr ( inode , & no_expand );
1980
1979
kfree (value );
1981
1980
if (inode -> i_nlink )
1982
1981
ext4_orphan_del (handle , inode );
@@ -1992,7 +1991,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1992
1991
1993
1992
int ext4_convert_inline_data (struct inode * inode )
1994
1993
{
1995
- int error , needed_blocks ;
1994
+ int error , needed_blocks , no_expand ;
1996
1995
handle_t * handle ;
1997
1996
struct ext4_iloc iloc ;
1998
1997
@@ -2014,15 +2013,10 @@ int ext4_convert_inline_data(struct inode *inode)
2014
2013
goto out_free ;
2015
2014
}
2016
2015
2017
- down_write (& EXT4_I (inode )-> xattr_sem );
2018
- if (!ext4_has_inline_data (inode )) {
2019
- up_write (& EXT4_I (inode )-> xattr_sem );
2020
- goto out ;
2021
- }
2022
-
2023
- error = ext4_convert_inline_data_nolock (handle , inode , & iloc );
2024
- up_write (& EXT4_I (inode )-> xattr_sem );
2025
- out :
2016
+ ext4_write_lock_xattr (inode , & no_expand );
2017
+ if (ext4_has_inline_data (inode ))
2018
+ error = ext4_convert_inline_data_nolock (handle , inode , & iloc );
2019
+ ext4_write_unlock_xattr (inode , & no_expand );
2026
2020
ext4_journal_stop (handle );
2027
2021
out_free :
2028
2022
brelse (iloc .bh );
0 commit comments