@@ -517,7 +517,8 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
517
517
/* Here we know that we can set the new attribute. */
518
518
519
519
if (header ) {
520
- /* assert(header == HDR(bh)); */
520
+ int offset ;
521
+
521
522
lock_buffer (bh );
522
523
if (header -> h_refcount == cpu_to_le32 (1 )) {
523
524
__u32 hash = le32_to_cpu (header -> h_hash );
@@ -531,22 +532,20 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
531
532
bh -> b_blocknr );
532
533
533
534
/* keep the buffer locked while modifying it. */
534
- } else {
535
- int offset ;
536
-
537
- unlock_buffer (bh );
538
- ea_bdebug (bh , "cloning" );
539
- header = kmemdup (HDR (bh ), bh -> b_size , GFP_KERNEL );
540
- error = - ENOMEM ;
541
- if (header == NULL )
542
- goto cleanup ;
543
- header -> h_refcount = cpu_to_le32 (1 );
544
-
545
- offset = (char * )here - bh -> b_data ;
546
- here = ENTRY ((char * )header + offset );
547
- offset = (char * )last - bh -> b_data ;
548
- last = ENTRY ((char * )header + offset );
535
+ goto update_block ;
549
536
}
537
+ unlock_buffer (bh );
538
+ ea_bdebug (bh , "cloning" );
539
+ header = kmemdup (HDR (bh ), bh -> b_size , GFP_KERNEL );
540
+ error = - ENOMEM ;
541
+ if (header == NULL )
542
+ goto cleanup ;
543
+ header -> h_refcount = cpu_to_le32 (1 );
544
+
545
+ offset = (char * )here - bh -> b_data ;
546
+ here = ENTRY ((char * )header + offset );
547
+ offset = (char * )last - bh -> b_data ;
548
+ last = ENTRY ((char * )header + offset );
550
549
} else {
551
550
/* Allocate a buffer where we construct the new block. */
552
551
header = kzalloc (sb -> s_blocksize , GFP_KERNEL );
@@ -559,6 +558,7 @@ ext2_xattr_set(struct inode *inode, int name_index, const char *name,
559
558
last = here = ENTRY (header + 1 );
560
559
}
561
560
561
+ update_block :
562
562
/* Iff we are modifying the block in-place, bh is locked here. */
563
563
564
564
if (not_found ) {
0 commit comments