@@ -316,48 +316,57 @@ static int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
316
316
return err ;
317
317
}
318
318
319
- static int ovl_link_up (struct dentry * parent , struct dentry * dentry )
319
+ struct ovl_copy_up_ctx {
320
+ struct dentry * parent ;
321
+ struct dentry * dentry ;
322
+ struct path lowerpath ;
323
+ struct kstat stat ;
324
+ struct kstat pstat ;
325
+ const char * link ;
326
+ struct dentry * destdir ;
327
+ struct qstr destname ;
328
+ struct dentry * workdir ;
329
+ bool tmpfile ;
330
+ bool origin ;
331
+ };
332
+
333
+ static int ovl_link_up (struct ovl_copy_up_ctx * c )
320
334
{
321
335
int err ;
322
336
struct dentry * upper ;
323
- struct dentry * upperdir = ovl_dentry_upper (parent );
337
+ struct dentry * upperdir = ovl_dentry_upper (c -> parent );
324
338
struct inode * udir = d_inode (upperdir );
325
339
326
- err = ovl_set_nlink_lower (dentry );
340
+ /* Mark parent "impure" because it may now contain non-pure upper */
341
+ err = ovl_set_impure (c -> parent , upperdir );
342
+ if (err )
343
+ return err ;
344
+
345
+ err = ovl_set_nlink_lower (c -> dentry );
327
346
if (err )
328
347
return err ;
329
348
330
349
inode_lock_nested (udir , I_MUTEX_PARENT );
331
- upper = lookup_one_len (dentry -> d_name .name , upperdir ,
332
- dentry -> d_name .len );
350
+ upper = lookup_one_len (c -> dentry -> d_name .name , upperdir ,
351
+ c -> dentry -> d_name .len );
333
352
err = PTR_ERR (upper );
334
353
if (!IS_ERR (upper )) {
335
- err = ovl_do_link (ovl_dentry_upper (dentry ), udir , upper , true);
354
+ err = ovl_do_link (ovl_dentry_upper (c -> dentry ), udir , upper ,
355
+ true);
336
356
dput (upper );
337
357
338
- if (!err )
339
- ovl_dentry_set_upper_alias (dentry );
358
+ if (!err ) {
359
+ /* Restore timestamps on parent (best effort) */
360
+ ovl_set_timestamps (upperdir , & c -> pstat );
361
+ ovl_dentry_set_upper_alias (c -> dentry );
362
+ }
340
363
}
341
364
inode_unlock (udir );
342
- ovl_set_nlink_upper (dentry );
365
+ ovl_set_nlink_upper (c -> dentry );
343
366
344
367
return err ;
345
368
}
346
369
347
- struct ovl_copy_up_ctx {
348
- struct dentry * parent ;
349
- struct dentry * dentry ;
350
- struct path lowerpath ;
351
- struct kstat stat ;
352
- struct kstat pstat ;
353
- const char * link ;
354
- struct dentry * destdir ;
355
- struct qstr destname ;
356
- struct dentry * workdir ;
357
- bool tmpfile ;
358
- bool origin ;
359
- };
360
-
361
370
static int ovl_install_temp (struct ovl_copy_up_ctx * c , struct dentry * temp ,
362
371
struct dentry * * newdentry )
363
372
{
@@ -629,7 +638,7 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
629
638
if (!ovl_dentry_upper (dentry ))
630
639
err = ovl_do_copy_up (& ctx );
631
640
if (!err && !ovl_dentry_has_upper_alias (dentry ))
632
- err = ovl_link_up (parent , dentry );
641
+ err = ovl_link_up (& ctx );
633
642
ovl_copy_up_end (dentry );
634
643
}
635
644
do_delayed_call (& done );
0 commit comments