@@ -371,13 +371,13 @@ int ovl_set_attr(struct ovl_fs *ofs, struct dentry *upperdentry,
371
371
return err ;
372
372
}
373
373
374
- struct ovl_fh * ovl_encode_real_fh (struct ovl_fs * ofs , struct inode * realinode ,
374
+ struct ovl_fh * ovl_encode_real_fh (struct ovl_fs * ofs , struct dentry * real ,
375
375
bool is_upper )
376
376
{
377
377
struct ovl_fh * fh ;
378
378
int fh_type , dwords ;
379
379
int buflen = MAX_HANDLE_SZ ;
380
- uuid_t * uuid = & realinode -> i_sb -> s_uuid ;
380
+ uuid_t * uuid = & real -> d_sb -> s_uuid ;
381
381
int err ;
382
382
383
383
/* Make sure the real fid stays 32bit aligned */
@@ -394,8 +394,7 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
394
394
* the price or reconnecting the dentry.
395
395
*/
396
396
dwords = buflen >> 2 ;
397
- fh_type = exportfs_encode_inode_fh (realinode , (void * )fh -> fb .fid ,
398
- & dwords , NULL , 0 );
397
+ fh_type = exportfs_encode_fh (real , (void * )fh -> fb .fid , & dwords , 0 );
399
398
buflen = (dwords << 2 );
400
399
401
400
err = - EIO ;
@@ -427,29 +426,29 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, struct inode *realinode,
427
426
return ERR_PTR (err );
428
427
}
429
428
430
- struct ovl_fh * ovl_get_origin_fh (struct ovl_fs * ofs , struct dentry * origin )
429
+ int ovl_set_origin (struct ovl_fs * ofs , struct dentry * lower ,
430
+ struct dentry * upper )
431
431
{
432
+ const struct ovl_fh * fh = NULL ;
433
+ int err ;
434
+
432
435
/*
433
436
* When lower layer doesn't support export operations store a 'null' fh,
434
437
* so we can use the overlay.origin xattr to distignuish between a copy
435
438
* up and a pure upper inode.
436
439
*/
437
- if (!ovl_can_decode_fh (origin -> d_sb ))
438
- return NULL ;
439
-
440
- return ovl_encode_real_fh (ofs , d_inode (origin ), false);
441
- }
442
-
443
- int ovl_set_origin_fh (struct ovl_fs * ofs , const struct ovl_fh * fh ,
444
- struct dentry * upper )
445
- {
446
- int err ;
440
+ if (ovl_can_decode_fh (lower -> d_sb )) {
441
+ fh = ovl_encode_real_fh (ofs , lower , false);
442
+ if (IS_ERR (fh ))
443
+ return PTR_ERR (fh );
444
+ }
447
445
448
446
/*
449
447
* Do not fail when upper doesn't support xattrs.
450
448
*/
451
449
err = ovl_check_setxattr (ofs , upper , OVL_XATTR_ORIGIN , fh -> buf ,
452
450
fh ? fh -> fb .len : 0 , 0 );
451
+ kfree (fh );
453
452
454
453
/* Ignore -EPERM from setting "user.*" on symlink/special */
455
454
return err == - EPERM ? 0 : err ;
@@ -462,7 +461,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
462
461
const struct ovl_fh * fh ;
463
462
int err ;
464
463
465
- fh = ovl_encode_real_fh (ofs , d_inode ( upper ) , true);
464
+ fh = ovl_encode_real_fh (ofs , upper , true);
466
465
if (IS_ERR (fh ))
467
466
return PTR_ERR (fh );
468
467
@@ -477,7 +476,7 @@ static int ovl_set_upper_fh(struct ovl_fs *ofs, struct dentry *upper,
477
476
*
478
477
* Caller must hold i_mutex on indexdir.
479
478
*/
480
- static int ovl_create_index (struct dentry * dentry , const struct ovl_fh * fh ,
479
+ static int ovl_create_index (struct dentry * dentry , struct dentry * origin ,
481
480
struct dentry * upper )
482
481
{
483
482
struct ovl_fs * ofs = OVL_FS (dentry -> d_sb );
@@ -503,7 +502,7 @@ static int ovl_create_index(struct dentry *dentry, const struct ovl_fh *fh,
503
502
if (WARN_ON (ovl_test_flag (OVL_INDEX , d_inode (dentry ))))
504
503
return - EIO ;
505
504
506
- err = ovl_get_index_name_fh ( fh , & name );
505
+ err = ovl_get_index_name ( ofs , origin , & name );
507
506
if (err )
508
507
return err ;
509
508
@@ -542,7 +541,6 @@ struct ovl_copy_up_ctx {
542
541
struct dentry * destdir ;
543
542
struct qstr destname ;
544
543
struct dentry * workdir ;
545
- const struct ovl_fh * origin_fh ;
546
544
bool origin ;
547
545
bool indexed ;
548
546
bool metacopy ;
@@ -639,7 +637,7 @@ static int ovl_copy_up_metadata(struct ovl_copy_up_ctx *c, struct dentry *temp)
639
637
* hard link.
640
638
*/
641
639
if (c -> origin ) {
642
- err = ovl_set_origin_fh (ofs , c -> origin_fh , temp );
640
+ err = ovl_set_origin (ofs , c -> lowerpath . dentry , temp );
643
641
if (err )
644
642
return err ;
645
643
}
@@ -751,7 +749,7 @@ static int ovl_copy_up_workdir(struct ovl_copy_up_ctx *c)
751
749
goto cleanup ;
752
750
753
751
if (S_ISDIR (c -> stat .mode ) && c -> indexed ) {
754
- err = ovl_create_index (c -> dentry , c -> origin_fh , temp );
752
+ err = ovl_create_index (c -> dentry , c -> lowerpath . dentry , temp );
755
753
if (err )
756
754
goto cleanup ;
757
755
}
@@ -863,8 +861,6 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
863
861
{
864
862
int err ;
865
863
struct ovl_fs * ofs = OVL_FS (c -> dentry -> d_sb );
866
- struct dentry * origin = c -> lowerpath .dentry ;
867
- struct ovl_fh * fh = NULL ;
868
864
bool to_index = false;
869
865
870
866
/*
@@ -881,33 +877,25 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
881
877
to_index = true;
882
878
}
883
879
884
- if (S_ISDIR (c -> stat .mode ) || c -> stat .nlink == 1 || to_index ) {
885
- fh = ovl_get_origin_fh (ofs , origin );
886
- if (IS_ERR (fh ))
887
- return PTR_ERR (fh );
888
-
889
- /* origin_fh may be NULL */
890
- c -> origin_fh = fh ;
880
+ if (S_ISDIR (c -> stat .mode ) || c -> stat .nlink == 1 || to_index )
891
881
c -> origin = true;
892
- }
893
882
894
883
if (to_index ) {
895
884
c -> destdir = ovl_indexdir (c -> dentry -> d_sb );
896
- err = ovl_get_index_name (ofs , origin , & c -> destname );
885
+ err = ovl_get_index_name (ofs , c -> lowerpath . dentry , & c -> destname );
897
886
if (err )
898
- goto out_free_fh ;
887
+ return err ;
899
888
} else if (WARN_ON (!c -> parent )) {
900
889
/* Disconnected dentry must be copied up to index dir */
901
- err = - EIO ;
902
- goto out_free_fh ;
890
+ return - EIO ;
903
891
} else {
904
892
/*
905
893
* Mark parent "impure" because it may now contain non-pure
906
894
* upper
907
895
*/
908
896
err = ovl_set_impure (c -> parent , c -> destdir );
909
897
if (err )
910
- goto out_free_fh ;
898
+ return err ;
911
899
}
912
900
913
901
/* Should we copyup with O_TMPFILE or with workdir? */
@@ -939,8 +927,6 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c)
939
927
out :
940
928
if (to_index )
941
929
kfree (c -> destname .name );
942
- out_free_fh :
943
- kfree (fh );
944
930
return err ;
945
931
}
946
932
0 commit comments