@@ -1850,6 +1850,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
1850
1850
#define header (x ) ((struct ext4_xattr_header *)(x))
1851
1851
1852
1852
if (s -> base ) {
1853
+ int offset = (char * )s -> here - bs -> bh -> b_data ;
1854
+
1853
1855
BUFFER_TRACE (bs -> bh , "get_write_access" );
1854
1856
error = ext4_journal_get_write_access (handle , sb , bs -> bh ,
1855
1857
EXT4_JTR_NONE );
@@ -1882,49 +1884,46 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
1882
1884
if (error )
1883
1885
goto cleanup ;
1884
1886
goto inserted ;
1885
- } else {
1886
- int offset = (char * )s -> here - bs -> bh -> b_data ;
1887
+ }
1888
+ unlock_buffer (bs -> bh );
1889
+ ea_bdebug (bs -> bh , "cloning" );
1890
+ s -> base = kmemdup (BHDR (bs -> bh ), bs -> bh -> b_size , GFP_NOFS );
1891
+ error = - ENOMEM ;
1892
+ if (s -> base == NULL )
1893
+ goto cleanup ;
1894
+ s -> first = ENTRY (header (s -> base )+ 1 );
1895
+ header (s -> base )-> h_refcount = cpu_to_le32 (1 );
1896
+ s -> here = ENTRY (s -> base + offset );
1897
+ s -> end = s -> base + bs -> bh -> b_size ;
1887
1898
1888
- unlock_buffer (bs -> bh );
1889
- ea_bdebug (bs -> bh , "cloning" );
1890
- s -> base = kmemdup (BHDR (bs -> bh ), bs -> bh -> b_size , GFP_NOFS );
1891
- error = - ENOMEM ;
1892
- if (s -> base == NULL )
1899
+ /*
1900
+ * If existing entry points to an xattr inode, we need
1901
+ * to prevent ext4_xattr_set_entry() from decrementing
1902
+ * ref count on it because the reference belongs to the
1903
+ * original block. In this case, make the entry look
1904
+ * like it has an empty value.
1905
+ */
1906
+ if (!s -> not_found && s -> here -> e_value_inum ) {
1907
+ ea_ino = le32_to_cpu (s -> here -> e_value_inum );
1908
+ error = ext4_xattr_inode_iget (inode , ea_ino ,
1909
+ le32_to_cpu (s -> here -> e_hash ),
1910
+ & tmp_inode );
1911
+ if (error )
1893
1912
goto cleanup ;
1894
- s -> first = ENTRY (header (s -> base )+ 1 );
1895
- header (s -> base )-> h_refcount = cpu_to_le32 (1 );
1896
- s -> here = ENTRY (s -> base + offset );
1897
- s -> end = s -> base + bs -> bh -> b_size ;
1898
1913
1899
- /*
1900
- * If existing entry points to an xattr inode, we need
1901
- * to prevent ext4_xattr_set_entry() from decrementing
1902
- * ref count on it because the reference belongs to the
1903
- * original block. In this case, make the entry look
1904
- * like it has an empty value.
1905
- */
1906
- if (!s -> not_found && s -> here -> e_value_inum ) {
1907
- ea_ino = le32_to_cpu (s -> here -> e_value_inum );
1908
- error = ext4_xattr_inode_iget (inode , ea_ino ,
1909
- le32_to_cpu (s -> here -> e_hash ),
1910
- & tmp_inode );
1911
- if (error )
1912
- goto cleanup ;
1913
-
1914
- if (!ext4_test_inode_state (tmp_inode ,
1915
- EXT4_STATE_LUSTRE_EA_INODE )) {
1916
- /*
1917
- * Defer quota free call for previous
1918
- * inode until success is guaranteed.
1919
- */
1920
- old_ea_inode_quota = le32_to_cpu (
1921
- s -> here -> e_value_size );
1922
- }
1923
- iput (tmp_inode );
1924
-
1925
- s -> here -> e_value_inum = 0 ;
1926
- s -> here -> e_value_size = 0 ;
1914
+ if (!ext4_test_inode_state (tmp_inode ,
1915
+ EXT4_STATE_LUSTRE_EA_INODE )) {
1916
+ /*
1917
+ * Defer quota free call for previous
1918
+ * inode until success is guaranteed.
1919
+ */
1920
+ old_ea_inode_quota = le32_to_cpu (
1921
+ s -> here -> e_value_size );
1927
1922
}
1923
+ iput (tmp_inode );
1924
+
1925
+ s -> here -> e_value_inum = 0 ;
1926
+ s -> here -> e_value_size = 0 ;
1928
1927
}
1929
1928
} else {
1930
1929
/* Allocate a buffer where we construct the new block. */
0 commit comments