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

« back to all changes in this revision

Viewing changes to fs/aufs/whout.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: whout.c,v 1.30 2008/01/28 05:01:42 sfjro Exp $ */
 
19
/* $Id: whout.c,v 1.34 2008/03/16 23:45:49 sfjro Exp $ */
20
20
 
21
21
#include <linux/fs.h>
22
22
#include <linux/namei.h>
87
87
        struct inode *h_dir;
88
88
        unsigned int flags;
89
89
 
90
 
        LKTRTrace("%.*s/%.*s, ndx{%p, %d}\n", AuDLNPair(h_parent),
91
 
                  wh_name->len, wh_name->name, ndx->nfsmnt, ndx->dlgt);
 
90
        LKTRTrace("%.*s/%.*s, ndx{%p, 0x%x}\n", AuDLNPair(h_parent),
 
91
                  wh_name->len, wh_name->name, ndx->nfsmnt, ndx->flags);
92
92
        h_dir = h_parent->d_inode;
93
93
        AuDebugOn(!S_ISDIR(h_dir->i_mode));
94
94
 
142
142
        h_dir = h_dentry->d_inode;
143
143
        AuDebugOn(!S_ISDIR(h_dir->i_mode));
144
144
 
145
 
        try_sio = au_test_perm(h_dir, MAY_EXEC, ndx->dlgt);
 
145
        try_sio = au_test_perm_sio(h_dir, MAY_EXEC,
 
146
                                   au_ftest_ndx(ndx->flags, DLGT));
146
147
        err = au_test_wh(h_dentry, &diropq_name, try_sio, ndx);
147
148
        AuTraceErr(err);
148
149
        return err;
214
215
int rename_whtmp(struct inode *dir, struct dentry *dentry, aufs_bindex_t bindex,
215
216
                 int noself)
216
217
{
217
 
        int err;
 
218
        int err, dlgt;
218
219
        struct inode *h_dir;
219
220
        struct dentry *h_dentry, *h_parent, *tmp_dentry;
220
221
        struct super_block *sb;
221
222
        struct aufs_hin_ignore ign;
222
223
        struct vfsub_args vargs;
223
224
        struct aufs_ndx ndx = {
 
225
                .flags  = 0,
224
226
                .nd     = NULL,
225
227
                //.br   = NULL
226
228
        };
233
235
        IMustLock(h_dir);
234
236
 
235
237
        sb = dentry->d_sb;
 
238
        dlgt = au_need_dlgt(sb);
 
239
        if (unlikely(dlgt))
 
240
                au_fset_ndx(ndx.flags, DLGT);
236
241
        ndx.nfsmnt = au_nfsmnt(sb, bindex);
237
 
        ndx.dlgt = au_need_dlgt(sb);
238
242
        tmp_dentry = lkup_whtmp(h_parent, &h_dentry->d_name, &ndx);
239
243
        //if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
240
244
        err = PTR_ERR(tmp_dentry);
241
245
        if (!IS_ERR(tmp_dentry)) {
242
246
                /* under the same dir, no need to lock_rename() */
243
 
                vfsub_args_init(&vargs, &ign, ndx.dlgt, 0);
 
247
                vfsub_args_init(&vargs, &ign, dlgt, 0);
244
248
                AuDebugOn(!S_ISDIR(dentry->d_inode->i_mode));
245
249
                if (unlikely(au_flag_test_udba_inotify(sb)
246
250
                             && !noself))
314
318
                err = 0;
315
319
                if (h_dentry->d_inode
316
320
                    && S_ISREG(h_dentry->d_inode->i_mode))
317
 
                        err = do_unlink_wh(h_dir, h_dentry, dir, ndx->dlgt);
 
321
                        err = do_unlink_wh(h_dir, h_dentry, dir,
 
322
                                           au_ftest_ndx(ndx->flags, DLGT));
318
323
                dput(h_dentry);
319
324
        } else
320
325
                err = PTR_ERR(h_dentry);
403
408
        };
404
409
        struct aufs_ndx ndx = {
405
410
                .nfsmnt = nfsmnt,
406
 
                .dlgt   = 0, /* always no dlgt */
 
411
                .flags  = 0, /* always no dlgt */
407
412
                .nd     = NULL,
408
413
                //.br   = NULL
409
414
        };
532
537
        AuDebugOn(!a->br->br_wh || !a->br->br_wh->d_inode || current->fsuid);
533
538
 
534
539
        err = 0;
535
 
        /* aufs big lock */
 
540
        /* big aufs lock */
536
541
        si_write_lock(a->sb);
537
542
        if (unlikely(!br_writable(a->br->br_perm)))
538
543
                goto out;
604
609
}
605
610
 
606
611
/*
607
 
 * create the whiteoute @wh.
 
612
 * create the whiteout @wh.
608
613
 */
609
614
static int link_or_create_wh(struct dentry *wh, struct super_block *sb,
610
615
                             aufs_bindex_t bindex, struct inode *dir)
648
653
 * create or remove the diropq.
649
654
 */
650
655
static struct dentry *do_diropq(struct dentry *dentry, aufs_bindex_t bindex,
651
 
                                struct au_diropq_flags *flags)
 
656
                                unsigned int flags)
652
657
{
653
658
        struct dentry *opq_dentry, *h_dentry;
654
659
        struct inode *h_dir;
655
 
        int err;
 
660
        int err, dlgt;
656
661
        struct super_block *sb;
657
662
        struct aufs_ndx ndx = {
 
663
                .flags  = 0,
658
664
                .nd     = NULL,
659
665
                //.br   = NULL
660
666
        };
661
667
 
662
 
        LKTRTrace("%.*s, bindex %d, do_create %d\n", AuDLNPair(dentry),
663
 
                  bindex, flags->create);
 
668
        LKTRTrace("%.*s, bindex %d, flags 0x%x\n",
 
669
                  AuDLNPair(dentry), bindex, flags);
664
670
        h_dentry = au_h_dptr_i(dentry, bindex);
665
671
        AuDebugOn(!h_dentry);
666
672
        h_dir = h_dentry->d_inode;
669
675
        /* already checked by au_test_perm(). */
670
676
        sb = dentry->d_sb;
671
677
        ndx.nfsmnt = au_nfsmnt(sb, bindex);
672
 
        ndx.dlgt = flags->dlgt;
 
678
        dlgt = 0;
 
679
        if (unlikely(au_ftest_diropq(flags, DLGT))) {
 
680
                dlgt = 1;
 
681
                au_fset_ndx(ndx.flags, DLGT);
 
682
        }
673
683
        opq_dentry = au_lkup_one(diropq_name.name, h_dentry, diropq_name.len,
674
684
                                 &ndx);
675
685
        //if (LktrCond) {dput(opq_dentry); opq_dentry = ERR_PTR(-1);}
676
686
        if (IS_ERR(opq_dentry))
677
687
                goto out;
678
688
 
679
 
        if (flags->create) {
 
689
        if (au_ftest_diropq(flags, CREATE)) {
680
690
                AuDebugOn(opq_dentry->d_inode);
681
691
                err = link_or_create_wh(opq_dentry, sb, bindex,
682
692
                                        dentry->d_inode);
688
698
        } else {
689
699
                AuDebugOn(/* !S_ISDIR(dentry->d_inode->i_mode)
690
700
                           * ||  */!opq_dentry->d_inode);
691
 
                err = do_unlink_wh(h_dir, opq_dentry, dentry->d_inode,
692
 
                                   ndx.dlgt);
 
701
                err = do_unlink_wh(h_dir, opq_dentry, dentry->d_inode, dlgt);
693
702
                //if (LktrCond) err = -1;
694
703
                if (!err)
695
704
                        set_dbdiropq(dentry, -1);
706
715
        struct dentry **errp;
707
716
        struct dentry *dentry;
708
717
        aufs_bindex_t bindex;
709
 
        struct au_diropq_flags *flags;
 
718
        unsigned int flags;
710
719
};
711
720
 
712
721
static void call_do_diropq(void *args)
716
725
}
717
726
 
718
727
struct dentry *sio_diropq(struct dentry *dentry, aufs_bindex_t bindex,
719
 
                          struct au_diropq_flags *flags)
 
728
                          unsigned int flags)
720
729
{
721
730
        struct dentry *diropq, *h_dentry;
722
731
 
723
 
        LKTRTrace("%.*s, bindex %d, do_create %d\n",
724
 
                  AuDLNPair(dentry), bindex, flags->create);
 
732
        LKTRTrace("%.*s, bindex %d, flags 0x%x\n",
 
733
                  AuDLNPair(dentry), bindex, flags);
725
734
 
726
735
        h_dentry = au_h_dptr_i(dentry, bindex);
727
 
        if (!au_test_perm(h_dentry->d_inode, MAY_EXEC | MAY_WRITE, flags->dlgt))
 
736
        if (!au_test_perm_sio(h_dentry->d_inode, MAY_EXEC | MAY_WRITE,
 
737
                              au_ftest_diropq(flags, DLGT)))
728
738
                diropq = do_diropq(dentry, bindex, flags);
729
739
        else {
730
740
                int wkq_err;
892
902
                aufs_bindex_t bindex, struct inode *dir, struct inode *inode,
893
903
                int noself)
894
904
{
895
 
        int err;
 
905
        int err, dlgt;
896
906
        struct inode *h_inode, *h_dir;
897
907
        struct super_block *sb;
898
908
        struct aufs_hin_ignore ign;
899
909
        struct vfsub_args vargs;
900
910
        struct aufs_ndx ndx = {
 
911
                .flags  = 0,
901
912
                .nd     = NULL,
902
913
                //.br   = NULL
903
914
        };
910
921
        IMustLock(h_dir);
911
922
 
912
923
        sb = inode->i_sb;
 
924
        dlgt = au_need_dlgt(sb);
 
925
        if (unlikely(dlgt))
 
926
                au_fset_ndx(ndx.flags, DLGT);
913
927
        ndx.nfsmnt = au_nfsmnt(sb, bindex);
914
 
        ndx.dlgt = au_need_dlgt(sb);
915
928
        h_inode = h_dentry->d_inode;
916
929
        AuDebugOn(h_inode != au_h_iptr_i(inode, bindex));
917
930
        hdir2_lock(h_inode, inode, bindex);
920
933
         * someone else might change some whiteouts while we were sleeping.
921
934
         * it means this whlist may have an obsoleted entry.
922
935
         */
923
 
        if (!au_test_perm(h_inode, MAY_EXEC | MAY_WRITE, ndx.dlgt))
 
936
        if (!au_test_perm_sio(h_inode, MAY_EXEC | MAY_WRITE, dlgt))
924
937
                err = del_wh_children(whlist, h_dentry, bindex, inode, &ndx);
925
938
        else {
926
939
                int wkq_err;
927
940
                /* ugly */
928
 
                int dlgt = ndx.dlgt;
 
941
                unsigned int flags = ndx.flags;
929
942
                struct del_wh_children_args args = {
930
943
                        .errp           = &err,
931
944
                        .whlist         = whlist,
935
948
                        .ndx            = &ndx
936
949
                };
937
950
 
938
 
                ndx.dlgt = 0;
 
951
                ndx.flags = 0;
939
952
                wkq_err = au_wkq_wait(call_del_wh_children, &args, /*dlgt*/0);
940
953
                if (unlikely(wkq_err))
941
954
                        err = wkq_err;
942
 
                ndx.dlgt = dlgt;
 
955
                ndx.flags = flags;
943
956
        }
944
957
        hdir_unlock(h_inode, inode, bindex);
945
958
 
946
959
        if (!err) {
947
 
                vfsub_args_init(&vargs, &ign, ndx.dlgt, 0);
 
960
                vfsub_args_init(&vargs, &ign, dlgt, 0);
948
961
                if (unlikely(au_flag_test_udba_inotify(sb)
949
962
                             && !noself))
950
963
                        vfsub_ign_hinode(&vargs, IN_DELETE_SELF,