~ubuntu-branches/ubuntu/utopic/aufs/utopic

« back to all changes in this revision

Viewing changes to fs/aufs/i_op_ren.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-01-30 15:27:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130152704-uvd64xgdg17ro2s8
Tags: 0+20080129-1
* New upstream snapshot
* 01_vserver_apparmor: Combined patch for vServer and AppArmor Kernels
  - AppArmor kernels have no ia_file, do not use it (LP: #182481)
  - AppArmor patch written by Joerg Schirottke for Kanotix (thank you!)
  - Replaces 01_vserver and 06_ubuntu
* 03_missing_headers: Define the magic numbers for XFS and TMPFS
* 04_sec_perm: Do not use security_inode_permission with kernel >= 2.6.24
* Inform about available pre-compiled modules in aufs-source description
* conf.mk:
  - Rewrite automatic configuration part, define a function and call it
  - Activate the AUFS_FAKE_DM only if the lhash patch has not been applied

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: i_op_ren.c,v 1.61 2007/11/19 01:09:25 sfjro Exp $ */
 
19
/* $Id: i_op_ren.c,v 1.63 2008/01/28 05:02:03 sfjro Exp $ */
20
20
 
21
21
#include "aufs.h"
22
22
 
426
426
        return btgt;
427
427
}
428
428
 
 
429
//todo: meaningless lock if CONFIG_AUFS_DEBUG is disabled.
 
430
static void au_hgdirs(struct aufs_hinode **hgdir, struct rename_args *a)
 
431
{
 
432
        struct dentry *gparent[2];
 
433
        struct inode *gdir;
 
434
 
 
435
        if (!a->udba)
 
436
                return;
 
437
 
 
438
        gparent[SRC] = NULL;
 
439
        if (!IS_ROOT(a->parent[SRC])) {
 
440
                gparent[SRC] = dget_parent(a->parent[SRC]);
 
441
                gdir = gparent[SRC]->d_inode;
 
442
                if (gparent[SRC] != a->parent[DST]) {
 
443
                        ii_read_lock_parent3(gdir);
 
444
                        hgdir[SRC] = itohi(gdir, a->btgt);
 
445
                        ii_read_unlock(gdir);
 
446
                } else
 
447
                        hgdir[SRC] = itohi(gdir, a->btgt);
 
448
                dput(gparent[SRC]);
 
449
        }
 
450
 
 
451
        if (!a->issamedir
 
452
            && !IS_ROOT(a->parent[DST])
 
453
            && a->parent[DST] != gparent[SRC]) {
 
454
                gparent[DST] = dget_parent(a->parent[DST]);
 
455
                gdir = gparent[DST]->d_inode;
 
456
                if (gparent[DST] != a->parent[SRC]) {
 
457
                        ii_read_lock_parent3(gdir);
 
458
                        hgdir[DST] = itohi(gdir, a->btgt);
 
459
                        ii_read_unlock(gdir);
 
460
                } else
 
461
                        hgdir[DST] = itohi(gdir, a->btgt);
 
462
                dput(gparent[DST]);
 
463
        }
 
464
}
 
465
 
429
466
int aufs_rename(struct inode *src_dir, struct dentry *src_dentry,
430
467
                struct inode *dir, struct dentry *dentry)
431
468
{
432
469
        int err, do_dt_dstdir, flags;
433
470
        aufs_bindex_t bend, bindex;
434
471
        struct inode *inode[2], *dirs[2];
 
472
        struct aufs_hinode *hgdir[2];
435
473
        enum { PARENT, CHILD };
436
474
        /* reduce stack space */
437
475
        struct {
531
569
                        goto out_children;
532
570
        }
533
571
 
 
572
        hgdir[SRC] = NULL;
 
573
        hgdir[DST] = NULL;
 
574
        au_hgdirs(hgdir, &p->a);
534
575
        p->a.h_parent[SRC] = au_h_dptr_i(p->a.parent[SRC], p->a.btgt);
535
576
        p->a.h_parent[DST] = au_h_dptr_i(p->a.parent[DST], p->a.btgt);
536
577
        dirs[0] = src_dir;
537
578
        dirs[1] = dir;
 
579
#ifdef DbgUdbaRace
 
580
        AuDbgSleep(DbgUdbaRace);
 
581
#endif
538
582
        hdir_lock_rename(p->a.h_parent, dirs, p->a.btgt, p->a.issamedir);
539
583
 
 
584
        /*
 
585
         * someone else might change our parent-child relationship directly,
 
586
         * bypassing aufs, while we are handling a systemcall for aufs.
 
587
         */
 
588
        err = -ENOENT;
 
589
        if (unlikely(p->a.bstart[SRC] == p->a.btgt
 
590
                     && p->a.h_parent[SRC]
 
591
                     != au_h_dptr_i(src_dentry, p->a.btgt)->d_parent))
 
592
                goto out_hdir;
 
593
        err = -EIO;
 
594
        if (unlikely(p->a.bstart[DST] == p->a.btgt
 
595
                     && p->a.h_parent[DST]
 
596
                     != au_h_dptr_i(dentry, p->a.btgt)->d_parent))
 
597
                goto out_hdir;
 
598
#if 0
 
599
        // revalidate h_dentries
 
600
        // test parent-gparent relationship
 
601
#endif
 
602
 
540
603
        /* store timestamps to be revertible */
541
 
        au_dtime_store(p->dt[PARENT] + SRC, p->a.parent[SRC], p->a.btgt,
542
 
                       p->a.h_parent[SRC]);
 
604
        au_dtime_store(p->dt[PARENT] + SRC, p->a.parent[SRC],
 
605
                       p->a.h_parent[SRC], hgdir[SRC]);
543
606
        if (!p->a.issamedir)
544
 
                au_dtime_store(p->dt[PARENT] + DST, p->a.parent[DST], p->a.btgt,
545
 
                               p->a.h_parent[DST]);
 
607
                au_dtime_store(p->dt[PARENT] + DST, p->a.parent[DST],
 
608
                               p->a.h_parent[DST], hgdir[DST]);
546
609
        do_dt_dstdir = 0;
547
610
        if (p->a.isdir) {
548
 
                au_dtime_store(p->dt[CHILD] + SRC, src_dentry, p->a.btgt,
549
 
                               p->a.h_dentry[SRC]);
 
611
                au_dtime_store
 
612
                        (p->dt[CHILD] + SRC, src_dentry, p->a.h_dentry[SRC],
 
613
                         itohi(p->a.parent[SRC]->d_inode, p->a.btgt));
550
614
                if (p->a.h_dentry[DST]->d_inode) {
551
615
                        do_dt_dstdir = 1;
552
 
                        au_dtime_store(p->dt[CHILD] + DST, dentry, p->a.btgt,
553
 
                                       p->a.h_dentry[DST]);
 
616
                        au_dtime_store
 
617
                                (p->dt[CHILD] + DST, dentry, p->a.h_dentry[DST],
 
618
                                 itohi(p->a.parent[DST]->d_inode, p->a.btgt));
554
619
                }
555
620
        }
556
621
 
649
714
                        vfsub_i_unlock(hd->d_inode);
650
715
                }
651
716
        }
 
717
 out_hdir:
652
718
        hdir_unlock_rename(p->a.h_parent, dirs, p->a.btgt, p->a.issamedir);
653
719
 out_children:
654
720
        nhash_fin(&p->a.whlist);