~ubuntu-branches/ubuntu/quantal/aufs/quantal

« back to all changes in this revision

Viewing changes to fs/aufs/cpup.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-04-01 18:26:37 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080401182637-ujuqq47eiggw4y5w
Tags: 0+20080401-1
* New upstream snapshot
  - Remove bashisms in script (Closes: #471288)
* debian/conf.mk, linux-patch-aufs.kpatches.sysfs_get_dentry:
  - Remove support for this patch, no longer used
* debian/conf.mk:
  - Add hacks for arm to armel (Closes: #473767)
* debian/control:
  - Add Dm-Upload-Allowed
* debian/copyright:
  - Use http://wiki.debian.org/Proposals/CopyrightFormat
* debian/linux-patch-aufs.kpatches.{splice,put_filp}:
  - Add support for Kernel 2.6.24 (and 2.6.25)
* debian/patches:
  - 01_vserver_apparmor: Update patch
  - 06_rt: Add patch for realtime kernel
  - 07_splice_hack: Add hack to support splice operations (Closes: #473430)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2005, 2006, 2007 Junjiro Okajima
 
2
 * Copyright (C) 2005, 2006, 2007, 2008 Junjiro Okajima
3
3
 *
4
4
 * This program, aufs is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
16
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 */
18
18
 
19
 
/* $Id: cpup.c,v 1.60 2008/01/21 04:55:55 sfjro Exp $ */
 
19
/* $Id: cpup.c,v 1.64 2008/03/24 02:15:04 sfjro Exp $ */
20
20
 
21
21
#include "aufs.h"
22
22
 
279
279
/* return with hidden dst inode is locked */
280
280
static int cpup_entry(struct dentry *dentry, aufs_bindex_t bdst,
281
281
                      aufs_bindex_t bsrc, loff_t len,
282
 
                      struct au_cpup_flags *flags, int dlgt)
 
282
                      unsigned int flags, int dlgt)
283
283
{
284
 
        int err, symlen;
 
284
        int err, symlen, isdir;
285
285
        struct dentry *h_src, *h_dst, *h_parent, *parent, *gparent;
286
286
        struct inode *h_inode, *h_dir, *dir;
287
287
        struct au_dtime dt;
291
291
        struct super_block *sb;
292
292
        struct vfsub_args vargs;
293
293
        struct aufs_hinode *hgdir;
294
 
        const int do_dt = flags->dtime;
 
294
        const int do_dt = au_ftest_cpup(flags, DTIME);
 
295
        const int udba = au_flag_test_udba_inotify(dentry->d_sb);
295
296
 
296
297
        LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, dtime %u\n",
297
298
                  AuDLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
305
306
        h_inode = h_src->d_inode;
306
307
        AuDebugOn(!h_inode);
307
308
 
308
 
        /* stop refrencing while we are creating */
 
309
        /* stop referencing while we are creating */
309
310
        parent = dget_parent(dentry);
310
311
        dir = parent->d_inode;
311
312
        h_dst = au_h_dptr_i(dentry, bdst);
316
317
 
317
318
        if (do_dt) {
318
319
                hgdir = NULL;
319
 
                if (unlikely(au_flag_test_udba_inotify(sb)
320
 
                             && !IS_ROOT(parent))) {
 
320
                if (unlikely(udba && !IS_ROOT(parent))) {
321
321
                        gparent = dget_parent(parent);
322
322
                        hgdir = itohi(gparent->d_inode, bdst);
323
323
                        dput(gparent);
325
325
                au_dtime_store(&dt, parent, h_parent, hgdir);
326
326
        }
327
327
 
 
328
        isdir = 0;
328
329
        mode = h_inode->i_mode;
329
330
        switch (mode & S_IFMT) {
330
331
        case S_IFREG:
355
356
                }
356
357
                break;
357
358
        case S_IFDIR:
 
359
                isdir = 1;
358
360
                err = vfsub_mkdir(h_dir, h_dst, mode, dlgt);
359
361
                //if (LktrCond) {vfs_rmdir(h_dir, h_dst); err = -1;}
360
362
                if (!err) {
401
403
                err = -EIO;
402
404
        }
403
405
 
 
406
        //todo: should it be always?
 
407
        if (unlikely(udba
 
408
                     && !isdir
 
409
                     && AuFlag(stosi(sb), f_xino)
 
410
                     && h_inode->i_nlink == 1
 
411
                     && bdst < bsrc))
 
412
                xino_write0(sb, bsrc, h_inode->i_ino, /*ino*/0);
 
413
                /* ignore this error */
 
414
 
404
415
        if (do_dt)
405
416
                au_dtime_revert(&dt);
406
417
        dput(parent);
411
422
/*
412
423
 * copyup the @dentry from @bsrc to @bdst.
413
424
 * the caller must set the both of hidden dentries.
414
 
 * @len is for trucating when it is -1 copyup the entire file.
 
425
 * @len is for truncating when it is -1 copyup the entire file.
415
426
 */
416
427
int au_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
417
 
                   aufs_bindex_t bsrc, loff_t len, struct au_cpup_flags *flags)
 
428
                   aufs_bindex_t bsrc, loff_t len, unsigned int flags)
418
429
{
419
430
        int err, rerr, isdir, dlgt;
420
431
        struct dentry *h_src, *h_dst, *parent, *h_parent, *gparent;
426
437
        struct aufs_sbinfo *sbinfo;
427
438
        struct aufs_hinode *hgdir;
428
439
 
429
 
        LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, dtime %u\n",
 
440
        LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
430
441
                  AuDLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
431
 
                  flags->dtime);
 
442
                  flags);
432
443
        sb = dentry->d_sb;
433
444
        AuDebugOn(bsrc <= bdst);
434
445
        h_dst = au_h_dptr_i(dentry, bdst);
530
541
        struct dentry *dentry;
531
542
        aufs_bindex_t bdst, bsrc;
532
543
        loff_t len;
533
 
        struct au_cpup_flags *flags;
 
544
        unsigned int flags;
534
545
};
535
546
 
536
547
static void au_call_cpup_single(void *args)
541
552
}
542
553
 
543
554
int au_sio_cpup_single(struct dentry *dentry, aufs_bindex_t bdst,
544
 
                       aufs_bindex_t bsrc, loff_t len,
545
 
                       struct au_cpup_flags *flags)
 
555
                       aufs_bindex_t bsrc, loff_t len, unsigned int flags)
546
556
{
547
557
        int err, wkq_err;
548
558
        struct dentry *h_dentry;
549
559
        umode_t mode;
550
560
 
551
 
        LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, dtime %u\n",
 
561
        LKTRTrace("%.*s, i%lu, bdst %d, bsrc %d, len %Ld, flags 0x%x\n",
552
562
                  AuDLNPair(dentry), dentry->d_inode->i_ino, bdst, bsrc, len,
553
 
                  flags->dtime);
 
563
                  flags);
554
564
 
555
565
        h_dentry = au_h_dptr_i(dentry, bsrc);
556
566
        mode = h_dentry->d_inode->i_mode & S_IFMT;
580
590
 * using au_cpup_single().
581
591
 */
582
592
int au_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
583
 
                   struct au_cpup_flags *flags)
 
593
                   unsigned int flags)
584
594
{
585
595
        int err;
586
596
        struct inode *inode;
587
597
        aufs_bindex_t bsrc, bend;
588
598
 
589
 
        LKTRTrace("%.*s, bdst %d, len %Ld, dtime %u\n",
590
 
                  AuDLNPair(dentry), bdst, len, flags->dtime);
 
599
        LKTRTrace("%.*s, bdst %d, len %Ld, flags 0x%x\n",
 
600
                  AuDLNPair(dentry), bdst, len, flags);
591
601
        inode = dentry->d_inode;
592
602
        AuDebugOn(!S_ISDIR(inode->i_mode) && dbstart(dentry) < bdst);
593
603
 
618
628
        struct dentry *dentry;
619
629
        aufs_bindex_t bdst;
620
630
        loff_t len;
621
 
        struct au_cpup_flags *flags;
 
631
        unsigned int flags;
622
632
};
623
633
 
624
634
static void au_call_cpup_simple(void *args)
628
638
}
629
639
 
630
640
int au_sio_cpup_simple(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
631
 
                       struct au_cpup_flags *flags)
 
641
                       unsigned int flags)
632
642
{
633
643
        int err, do_sio, dlgt, wkq_err;
634
644
        struct dentry *parent;
635
645
        struct inode *h_dir, *dir;
636
646
 
637
 
        LKTRTrace("%.*s, b%d, len %Ld, dtime %u\n",
638
 
                  AuDLNPair(dentry), bdst, len, flags->dtime);
 
647
        LKTRTrace("%.*s, b%d, len %Ld, flags 0x%x\n",
 
648
                  AuDLNPair(dentry), bdst, len, flags);
639
649
 
640
650
        parent = dget_parent(dentry);
641
651
        dir = parent->d_inode;
642
652
        h_dir = au_h_iptr_i(dir, bdst);
643
653
        dlgt = au_need_dlgt(dir->i_sb);
644
 
        do_sio = au_test_perm(h_dir, MAY_EXEC | MAY_WRITE, dlgt);
 
654
        do_sio = au_test_perm_sio(h_dir, MAY_EXEC | MAY_WRITE, dlgt);
645
655
        if (!do_sio) {
646
656
                /*
647
657
                 * testing CAP_MKNOD is for generic fs,
681
691
int au_cpup_wh(struct dentry *dentry, aufs_bindex_t bdst, loff_t len,
682
692
               struct file *file)
683
693
{
684
 
        int err;
 
694
        int err, dlgt;
685
695
        struct dentry *parent, *h_parent, *wh_dentry, *h_dentry_bdst,
686
696
                *h_dentry_bstart, *gparent;
687
697
        struct inode *h_dir;
693
703
        struct aufs_hinode *hgdir;
694
704
        struct aufs_ndx ndx = {
695
705
                .nd     = NULL,
 
706
                .flags  = 0,
696
707
                //.br   = NULL
697
708
        };
698
 
        struct au_cpup_flags cflags = {
699
 
                .dtime = 0
700
 
        };
701
709
 
702
710
        LKTRTrace("%.*s, bdst %d, len %Lu\n", AuDLNPair(dentry), bdst, len);
703
711
        AuDebugOn(S_ISDIR(dentry->d_inode->i_mode)
712
720
        AuDebugOn(!h_dir);
713
721
 
714
722
        sb = parent->d_sb;
 
723
        dlgt = 0;
715
724
        ndx.nfsmnt = au_nfsmnt(sb, bdst);
716
 
        ndx.dlgt = au_need_dlgt(sb);
 
725
        if (unlikely(au_need_dlgt(sb))) {
 
726
                dlgt = 1;
 
727
                au_fset_ndx(ndx.flags, DLGT);
 
728
        }
717
729
        wh_dentry = lkup_whtmp(h_parent, &dentry->d_name, &ndx);
718
730
        //if (LktrCond) {dput(wh_dentry); wh_dentry = ERR_PTR(-1);}
719
731
        err = PTR_ERR(wh_dentry);
736
748
        if (file)
737
749
                dinfo->di_hdentry[0 + bstart].hd_dentry
738
750
                        = au_h_fptr(file)->f_dentry;
739
 
        err = au_cpup_single(dentry, bdst, bstart, len, &cflags);
 
751
        err = au_cpup_single(dentry, bdst, bstart, len, !AuCpup_DTIME);
740
752
        //if (LktrCond) err = -1;
741
753
        if (!err && file) {
742
754
                err = au_reopen_nondir(file);
751
763
        AuDebugOn(!d_unhashed(dentry));
752
764
        /* dget first to force sillyrename on nfs */
753
765
        dget(wh_dentry);
754
 
        vfsub_args_init(&vargs, NULL, ndx.dlgt, 0);
 
766
        vfsub_args_init(&vargs, NULL, dlgt, 0);
755
767
        err = vfsub_unlink(h_dir, wh_dentry, &vargs);
756
768
        //if (LktrCond) err = -1;
757
769
        if (unlikely(err)) {
798
810
        IiMustAnyLock(dir);
799
811
        h_dir = au_h_iptr_i(dir, bdst);
800
812
 
801
 
        if (!au_test_perm(h_dir, MAY_EXEC | MAY_WRITE,
802
 
                          au_need_dlgt(dentry->d_sb)))
 
813
        if (!au_test_perm_sio(h_dir, MAY_EXEC | MAY_WRITE,
 
814
                              au_need_dlgt(dentry->d_sb)))
803
815
                err = au_cpup_wh(dentry, bdst, len, file);
804
816
        else {
805
817
                struct au_cpup_wh_args args = {
925
937
                       struct dentry *h_parent, void *arg)
926
938
{
927
939
        int err;
928
 
        struct au_cpup_flags cflags = {
929
 
                .dtime = 1
930
 
        };
931
940
 
932
 
        err = au_sio_cpup_simple(dentry, bdst, -1, &cflags);
 
941
        err = au_sio_cpup_simple(dentry, bdst, -1, AuCpup_DTIME);
933
942
 
934
943
        AuTraceErr(err);
935
944
        return err;