@@ -381,7 +381,7 @@ static int ext4_update_inline_data(handle_t *handle, struct inode *inode,
381
381
static int ext4_prepare_inline_data (handle_t * handle , struct inode * inode ,
382
382
unsigned int len )
383
383
{
384
- int ret , size ;
384
+ int ret , size , no_expand ;
385
385
struct ext4_inode_info * ei = EXT4_I (inode );
386
386
387
387
if (!ext4_test_inode_state (inode , EXT4_STATE_MAY_INLINE_DATA ))
@@ -391,15 +391,14 @@ static int ext4_prepare_inline_data(handle_t *handle, struct inode *inode,
391
391
if (size < len )
392
392
return - ENOSPC ;
393
393
394
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
394
+ ext4_write_lock_xattr ( inode , & no_expand );
395
395
396
396
if (ei -> i_inline_off )
397
397
ret = ext4_update_inline_data (handle , inode , len );
398
398
else
399
399
ret = ext4_create_inline_data (handle , inode , len );
400
400
401
- up_write (& EXT4_I (inode )-> xattr_sem );
402
-
401
+ ext4_write_unlock_xattr (inode , & no_expand );
403
402
return ret ;
404
403
}
405
404
@@ -533,7 +532,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
533
532
struct inode * inode ,
534
533
unsigned flags )
535
534
{
536
- int ret , needed_blocks ;
535
+ int ret , needed_blocks , no_expand ;
537
536
handle_t * handle = NULL ;
538
537
int retries = 0 , sem_held = 0 ;
539
538
struct page * page = NULL ;
@@ -573,7 +572,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
573
572
goto out ;
574
573
}
575
574
576
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
575
+ ext4_write_lock_xattr ( inode , & no_expand );
577
576
sem_held = 1 ;
578
577
/* If some one has already done this for us, just exit. */
579
578
if (!ext4_has_inline_data (inode )) {
@@ -610,7 +609,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
610
609
put_page (page );
611
610
page = NULL ;
612
611
ext4_orphan_add (handle , inode );
613
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
612
+ ext4_write_unlock_xattr ( inode , & no_expand );
614
613
sem_held = 0 ;
615
614
ext4_journal_stop (handle );
616
615
handle = NULL ;
@@ -636,7 +635,7 @@ static int ext4_convert_inline_data_to_extent(struct address_space *mapping,
636
635
put_page (page );
637
636
}
638
637
if (sem_held )
639
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
638
+ ext4_write_unlock_xattr ( inode , & no_expand );
640
639
if (handle )
641
640
ext4_journal_stop (handle );
642
641
brelse (iloc .bh );
@@ -729,7 +728,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
729
728
int ext4_write_inline_data_end (struct inode * inode , loff_t pos , unsigned len ,
730
729
unsigned copied , struct page * page )
731
730
{
732
- int ret ;
731
+ int ret , no_expand ;
733
732
void * kaddr ;
734
733
struct ext4_iloc iloc ;
735
734
@@ -747,7 +746,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
747
746
goto out ;
748
747
}
749
748
750
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
749
+ ext4_write_lock_xattr ( inode , & no_expand );
751
750
BUG_ON (!ext4_has_inline_data (inode ));
752
751
753
752
kaddr = kmap_atomic (page );
@@ -757,7 +756,7 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
757
756
/* clear page dirty so that writepages wouldn't work for us. */
758
757
ClearPageDirty (page );
759
758
760
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
759
+ ext4_write_unlock_xattr ( inode , & no_expand );
761
760
brelse (iloc .bh );
762
761
out :
763
762
return copied ;
@@ -768,7 +767,7 @@ ext4_journalled_write_inline_data(struct inode *inode,
768
767
unsigned len ,
769
768
struct page * page )
770
769
{
771
- int ret ;
770
+ int ret , no_expand ;
772
771
void * kaddr ;
773
772
struct ext4_iloc iloc ;
774
773
@@ -778,11 +777,11 @@ ext4_journalled_write_inline_data(struct inode *inode,
778
777
return NULL ;
779
778
}
780
779
781
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
780
+ ext4_write_lock_xattr ( inode , & no_expand );
782
781
kaddr = kmap_atomic (page );
783
782
ext4_write_inline_data (inode , & iloc , kaddr , 0 , len );
784
783
kunmap_atomic (kaddr );
785
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
784
+ ext4_write_unlock_xattr ( inode , & no_expand );
786
785
787
786
return iloc .bh ;
788
787
}
@@ -1259,15 +1258,15 @@ static int ext4_convert_inline_data_nolock(handle_t *handle,
1259
1258
int ext4_try_add_inline_entry (handle_t * handle , struct ext4_filename * fname ,
1260
1259
struct inode * dir , struct inode * inode )
1261
1260
{
1262
- int ret , inline_size ;
1261
+ int ret , inline_size , no_expand ;
1263
1262
void * inline_start ;
1264
1263
struct ext4_iloc iloc ;
1265
1264
1266
1265
ret = ext4_get_inode_loc (dir , & iloc );
1267
1266
if (ret )
1268
1267
return ret ;
1269
1268
1270
- down_write ( & EXT4_I ( dir ) -> xattr_sem );
1269
+ ext4_write_lock_xattr ( dir , & no_expand );
1271
1270
if (!ext4_has_inline_data (dir ))
1272
1271
goto out ;
1273
1272
@@ -1313,7 +1312,7 @@ int ext4_try_add_inline_entry(handle_t *handle, struct ext4_filename *fname,
1313
1312
1314
1313
out :
1315
1314
ext4_mark_inode_dirty (handle , dir );
1316
- up_write ( & EXT4_I ( dir ) -> xattr_sem );
1315
+ ext4_write_unlock_xattr ( dir , & no_expand );
1317
1316
brelse (iloc .bh );
1318
1317
return ret ;
1319
1318
}
@@ -1673,15 +1672,15 @@ int ext4_delete_inline_entry(handle_t *handle,
1673
1672
struct buffer_head * bh ,
1674
1673
int * has_inline_data )
1675
1674
{
1676
- int err , inline_size ;
1675
+ int err , inline_size , no_expand ;
1677
1676
struct ext4_iloc iloc ;
1678
1677
void * inline_start ;
1679
1678
1680
1679
err = ext4_get_inode_loc (dir , & iloc );
1681
1680
if (err )
1682
1681
return err ;
1683
1682
1684
- down_write ( & EXT4_I ( dir ) -> xattr_sem );
1683
+ ext4_write_lock_xattr ( dir , & no_expand );
1685
1684
if (!ext4_has_inline_data (dir )) {
1686
1685
* has_inline_data = 0 ;
1687
1686
goto out ;
@@ -1715,7 +1714,7 @@ int ext4_delete_inline_entry(handle_t *handle,
1715
1714
1716
1715
ext4_show_inline_dir (dir , iloc .bh , inline_start , inline_size );
1717
1716
out :
1718
- up_write ( & EXT4_I ( dir ) -> xattr_sem );
1717
+ ext4_write_unlock_xattr ( dir , & no_expand );
1719
1718
brelse (iloc .bh );
1720
1719
if (err != - ENOENT )
1721
1720
ext4_std_error (dir -> i_sb , err );
@@ -1814,11 +1813,11 @@ bool empty_inline_dir(struct inode *dir, int *has_inline_data)
1814
1813
1815
1814
int ext4_destroy_inline_data (handle_t * handle , struct inode * inode )
1816
1815
{
1817
- int ret ;
1816
+ int ret , no_expand ;
1818
1817
1819
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
1818
+ ext4_write_lock_xattr ( inode , & no_expand );
1820
1819
ret = ext4_destroy_inline_data_nolock (handle , inode );
1821
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
1820
+ ext4_write_unlock_xattr ( inode , & no_expand );
1822
1821
1823
1822
return ret ;
1824
1823
}
@@ -1903,7 +1902,7 @@ int ext4_try_to_evict_inline_data(handle_t *handle,
1903
1902
void ext4_inline_data_truncate (struct inode * inode , int * has_inline )
1904
1903
{
1905
1904
handle_t * handle ;
1906
- int inline_size , value_len , needed_blocks ;
1905
+ int inline_size , value_len , needed_blocks , no_expand ;
1907
1906
size_t i_size ;
1908
1907
void * value = NULL ;
1909
1908
struct ext4_xattr_ibody_find is = {
@@ -1920,7 +1919,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1920
1919
if (IS_ERR (handle ))
1921
1920
return ;
1922
1921
1923
- down_write ( & EXT4_I ( inode ) -> xattr_sem );
1922
+ ext4_write_lock_xattr ( inode , & no_expand );
1924
1923
if (!ext4_has_inline_data (inode )) {
1925
1924
* has_inline = 0 ;
1926
1925
ext4_journal_stop (handle );
@@ -1978,7 +1977,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1978
1977
up_write (& EXT4_I (inode )-> i_data_sem );
1979
1978
out :
1980
1979
brelse (is .iloc .bh );
1981
- up_write ( & EXT4_I ( inode ) -> xattr_sem );
1980
+ ext4_write_unlock_xattr ( inode , & no_expand );
1982
1981
kfree (value );
1983
1982
if (inode -> i_nlink )
1984
1983
ext4_orphan_del (handle , inode );
@@ -1994,7 +1993,7 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
1994
1993
1995
1994
int ext4_convert_inline_data (struct inode * inode )
1996
1995
{
1997
- int error , needed_blocks ;
1996
+ int error , needed_blocks , no_expand ;
1998
1997
handle_t * handle ;
1999
1998
struct ext4_iloc iloc ;
2000
1999
@@ -2016,15 +2015,10 @@ int ext4_convert_inline_data(struct inode *inode)
2016
2015
goto out_free ;
2017
2016
}
2018
2017
2019
- down_write (& EXT4_I (inode )-> xattr_sem );
2020
- if (!ext4_has_inline_data (inode )) {
2021
- up_write (& EXT4_I (inode )-> xattr_sem );
2022
- goto out ;
2023
- }
2024
-
2025
- error = ext4_convert_inline_data_nolock (handle , inode , & iloc );
2026
- up_write (& EXT4_I (inode )-> xattr_sem );
2027
- out :
2018
+ ext4_write_lock_xattr (inode , & no_expand );
2019
+ if (ext4_has_inline_data (inode ))
2020
+ error = ext4_convert_inline_data_nolock (handle , inode , & iloc );
2021
+ ext4_write_unlock_xattr (inode , & no_expand );
2028
2022
ext4_journal_stop (handle );
2029
2023
out_free :
2030
2024
brelse (iloc .bh );
0 commit comments