File tree Expand file tree Collapse file tree 3 files changed +28
-19
lines changed Expand file tree Collapse file tree 3 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -761,21 +761,7 @@ int ovl_copy_up_flags(struct dentry *dentry, int flags)
761
761
struct dentry * next ;
762
762
struct dentry * parent = NULL ;
763
763
764
- /*
765
- * Check if copy-up has happened as well as for upper alias (in
766
- * case of hard links) is there.
767
- *
768
- * Both checks are lockless:
769
- * - false negatives: will recheck under oi->lock
770
- * - false positives:
771
- * + ovl_dentry_upper() uses memory barriers to ensure the
772
- * upper dentry is up-to-date
773
- * + ovl_dentry_has_upper_alias() relies on locking of
774
- * upper parent i_rwsem to prevent reordering copy-up
775
- * with rename.
776
- */
777
- if (ovl_dentry_upper (dentry ) &&
778
- (ovl_dentry_has_upper_alias (dentry ) || disconnected ))
764
+ if (ovl_already_copied_up (dentry ))
779
765
break ;
780
766
781
767
next = dget (dentry );
@@ -803,9 +789,7 @@ int ovl_copy_up_flags(struct dentry *dentry, int flags)
803
789
static bool ovl_open_need_copy_up (struct dentry * dentry , int flags )
804
790
{
805
791
/* Copy up of disconnected dentry does not set upper alias */
806
- if (ovl_dentry_upper (dentry ) &&
807
- (ovl_dentry_has_upper_alias (dentry ) ||
808
- (dentry -> d_flags & DCACHE_DISCONNECTED )))
792
+ if (ovl_already_copied_up (dentry ))
809
793
return false;
810
794
811
795
if (special_file (d_inode (dentry )-> i_mode ))
Original file line number Diff line number Diff line change @@ -238,6 +238,7 @@ bool ovl_is_whiteout(struct dentry *dentry);
238
238
struct file * ovl_path_open (struct path * path , int flags );
239
239
int ovl_copy_up_start (struct dentry * dentry );
240
240
void ovl_copy_up_end (struct dentry * dentry );
241
+ bool ovl_already_copied_up (struct dentry * dentry );
241
242
bool ovl_check_origin_xattr (struct dentry * dentry );
242
243
bool ovl_check_dir_xattr (struct dentry * dentry , const char * name );
243
244
int ovl_check_setxattr (struct dentry * dentry , struct dentry * upperdentry ,
Original file line number Diff line number Diff line change @@ -377,13 +377,37 @@ struct file *ovl_path_open(struct path *path, int flags)
377
377
return dentry_open (path , flags | O_NOATIME , current_cred ());
378
378
}
379
379
380
+ bool ovl_already_copied_up (struct dentry * dentry )
381
+ {
382
+ bool disconnected = dentry -> d_flags & DCACHE_DISCONNECTED ;
383
+
384
+ /*
385
+ * Check if copy-up has happened as well as for upper alias (in
386
+ * case of hard links) is there.
387
+ *
388
+ * Both checks are lockless:
389
+ * - false negatives: will recheck under oi->lock
390
+ * - false positives:
391
+ * + ovl_dentry_upper() uses memory barriers to ensure the
392
+ * upper dentry is up-to-date
393
+ * + ovl_dentry_has_upper_alias() relies on locking of
394
+ * upper parent i_rwsem to prevent reordering copy-up
395
+ * with rename.
396
+ */
397
+ if (ovl_dentry_upper (dentry ) &&
398
+ (ovl_dentry_has_upper_alias (dentry ) || disconnected ))
399
+ return true;
400
+
401
+ return false;
402
+ }
403
+
380
404
int ovl_copy_up_start (struct dentry * dentry )
381
405
{
382
406
struct ovl_inode * oi = OVL_I (d_inode (dentry ));
383
407
int err ;
384
408
385
409
err = mutex_lock_interruptible (& oi -> lock );
386
- if (!err && ovl_dentry_has_upper_alias (dentry )) {
410
+ if (!err && ovl_already_copied_up (dentry )) {
387
411
err = 1 ; /* Already copied up */
388
412
mutex_unlock (& oi -> lock );
389
413
}
You can’t perform that action at this time.
0 commit comments