copy_up.c (2ea98466491b7609ace297647b07c28d99ef3722) copy_up.c (a6c6065511411c57167a6cdae0c33263fb662b51)
1/*
2 *
3 * Copyright (C) 2011 Novell Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 */

--- 310 unchanged lines hidden (view full) ---

319out_cleanup:
320 ovl_cleanup(wdir, newdentry);
321 goto out2;
322}
323
324/*
325 * Copy up a single dentry
326 *
1/*
2 *
3 * Copyright (C) 2011 Novell Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 */

--- 310 unchanged lines hidden (view full) ---

319out_cleanup:
320 ovl_cleanup(wdir, newdentry);
321 goto out2;
322}
323
324/*
325 * Copy up a single dentry
326 *
327 * Directory renames only allowed on "pure upper" (already created on
328 * upper filesystem, never copied up). Directories which are on lower or
329 * are merged may not be renamed. For these -EXDEV is returned and
330 * userspace has to deal with it. This means, when copying up a
331 * directory we can rely on it and ancestors being stable.
332 *
333 * Non-directory renames start with copy up of source if necessary. The
334 * actual rename will only proceed once the copy up was successful. Copy
335 * up uses upper parent i_mutex for exclusion. Since rename can change
336 * d_parent it is possible that the copy up will lock the old parent. At
337 * that point the file will have already been copied up anyway.
327 * All renames start with copy up of source if necessary. The actual
328 * rename will only proceed once the copy up was successful. Copy up uses
329 * upper parent i_mutex for exclusion. Since rename can change d_parent it
330 * is possible that the copy up will lock the old parent. At that point
331 * the file will have already been copied up anyway.
338 */
339int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
340 struct path *lowerpath, struct kstat *stat)
341{
342 DEFINE_DELAYED_CALL(done);
343 struct dentry *workdir = ovl_workdir(dentry);
344 int err;
345 struct kstat pstat;
346 struct path parentpath;
347 struct dentry *lowerdentry = lowerpath->dentry;
348 struct dentry *upperdir;
332 */
333int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry,
334 struct path *lowerpath, struct kstat *stat)
335{
336 DEFINE_DELAYED_CALL(done);
337 struct dentry *workdir = ovl_workdir(dentry);
338 int err;
339 struct kstat pstat;
340 struct path parentpath;
341 struct dentry *lowerdentry = lowerpath->dentry;
342 struct dentry *upperdir;
349 struct dentry *upperdentry;
350 const char *link = NULL;
351
352 if (WARN_ON(!workdir))
353 return -EROFS;
354
355 ovl_do_check_copy_up(lowerdentry);
356
357 ovl_path_upper(parent, &parentpath);

--- 9 unchanged lines hidden (view full) ---

367 return PTR_ERR(link);
368 }
369
370 err = -EIO;
371 if (lock_rename(workdir, upperdir) != NULL) {
372 pr_err("overlayfs: failed to lock workdir+upperdir\n");
373 goto out_unlock;
374 }
343 const char *link = NULL;
344
345 if (WARN_ON(!workdir))
346 return -EROFS;
347
348 ovl_do_check_copy_up(lowerdentry);
349
350 ovl_path_upper(parent, &parentpath);

--- 9 unchanged lines hidden (view full) ---

360 return PTR_ERR(link);
361 }
362
363 err = -EIO;
364 if (lock_rename(workdir, upperdir) != NULL) {
365 pr_err("overlayfs: failed to lock workdir+upperdir\n");
366 goto out_unlock;
367 }
375 upperdentry = ovl_dentry_upper(dentry);
376 if (upperdentry) {
368 if (ovl_dentry_upper(dentry)) {
377 /* Raced with another copy-up? Nothing to do, then... */
378 err = 0;
379 goto out_unlock;
380 }
381
382 err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath,
383 stat, link);
384 if (!err) {

--- 50 unchanged lines hidden ---
369 /* Raced with another copy-up? Nothing to do, then... */
370 err = 0;
371 goto out_unlock;
372 }
373
374 err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath,
375 stat, link);
376 if (!err) {

--- 50 unchanged lines hidden ---