SOURCES: kernel-aufs.patch (NEW) - latest and last version of AUFS (2009/01...

baggins baggins at pld-linux.org
Fri Mar 13 00:08:20 CET 2009


Author: baggins                      Date: Thu Mar 12 23:08:20 2009 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- latest and last version of AUFS (2009/01/26), in the form of a kernel patch

---- Files affected:
SOURCES:
   kernel-aufs.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/kernel-aufs.patch
diff -u /dev/null SOURCES/kernel-aufs.patch:1.1
--- /dev/null	Fri Mar 13 00:08:21 2009
+++ SOURCES/kernel-aufs.patch	Fri Mar 13 00:08:15 2009
@@ -0,0 +1,29634 @@
+diff -urN linux/fs/aufs/aufs.h linux-aufs/fs/aufs/aufs.h
+--- linux/fs/aufs/aufs.h	1970-01-01 01:00:00.000000000 +0100
++++ linux-aufs/fs/aufs/aufs.h	2009-03-12 16:18:04.000000000 +0100
+@@ -0,0 +1,70 @@
++/*
++ * Copyright (C) 2005-2009 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
++ */
++
++/*
++ * main header files
++ *
++ * $Id$
++ */
++
++#ifndef __AUFS_H__
++#define __AUFS_H__
++
++#ifdef __KERNEL__
++
++#include <linux/version.h>
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
++#error you got wrong version
++#endif
++
++/* introduced in linux-2.6.27 */
++#include <linux/bug.h>
++#ifndef WARN_ONCE
++#define WARN_ONCE(cond, fmt ...) WARN_ON(cond)
++#endif
++
++/* ---------------------------------------------------------------------- */
++
++#include "debug.h"
++
++#include "branch.h"
++#include "cpup.h"
++#include "dcsub.h"
++#include "dentry.h"
++#include "dir.h"
++#include "file.h"
++#include "hinode.h"
++#include "inode.h"
++#include "misc.h"
++#include "module.h"
++#include "opts.h"
++#include "super.h"
++#include "sysaufs.h"
++#include "vfsub.h"
++#include "whout.h"
++#include "wkq.h"
++/* reserved for future use */
++/* #include "xattr.h" */
++
++#ifdef AuNoInlineForStack
++#undef noinline_for_stack
++#define noinline_for_stack /* */
++#endif
++
++#endif /* __KERNEL__ */
++#endif /* __AUFS_H__ */
+diff -urN linux/fs/aufs/branch.c linux-aufs/fs/aufs/branch.c
+--- linux/fs/aufs/branch.c	1970-01-01 01:00:00.000000000 +0100
++++ linux-aufs/fs/aufs/branch.c	2009-03-12 16:18:04.000000000 +0100
+@@ -0,0 +1,1038 @@
++/*
++ * Copyright (C) 2005-2009 Junjiro Okajima
++ *
++ * This program, aufs is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
++ */
++
++/*
++ * branch management
++ *
++ * $Id$
++ */
++
++#include <linux/iso_fs.h>
++#include <linux/loop.h>
++#include <linux/romfs_fs.h>
++#include <linux/smp_lock.h>
++#include "aufs.h"
++
++static void au_br_do_free(struct au_branch *br)
++{
++	int i;
++	struct au_wbr *wbr;
++
++	AuTraceEnter();
++
++	if (br->br_xino.xi_file)
++		fput(br->br_xino.xi_file);
++	mutex_destroy(&br->br_xino.xi_nondir_mtx);
++	wbr = br->br_wbr;
++	if (wbr)
++		for (i = 0; i < AuBrWh_Last; i++)
++			dput(wbr->wbr_wh[i]);
++	/* do not call au_br_nfs_lockdep_off() here */
++	if (br->br_mnt && !au_test_nfs(br->br_mnt->mnt_sb))
++		mntput(br->br_mnt);
++	else {
++		lockdep_off();
++		mntput(br->br_mnt);
++		lockdep_on();
++	}
++	AuDebugOn(au_br_count(br));
++	if (wbr) {
++		AuDebugOn(atomic_read(&wbr->wbr_wh_running));
++		au_rwsem_destroy(&wbr->wbr_wh_rwsem);
++	}
++	kfree(wbr);
++	kfree(br);
++}
++
++/*
++ * frees all branches
++ */
++void au_br_free(struct au_sbinfo *sbinfo)
++{
++	aufs_bindex_t bmax;
++	struct au_branch **br;
++
++	AuTraceEnter();
++	bmax = sbinfo->si_bend + 1;
++	br = sbinfo->si_branch;
++	while (bmax--)
++		au_br_do_free(*br++);
++}
++
++/*
++ * find the index of a branch which is specified by @br_id.
++ */
++int au_br_index(struct super_block *sb, aufs_bindex_t br_id)
++{
++	aufs_bindex_t bindex, bend;
++
++	AuTraceEnter();
++
++	bend = au_sbend(sb);
++	for (bindex = 0; bindex <= bend; bindex++)
++		if (au_sbr_id(sb, bindex) == br_id)
++			return bindex;
++	return -1;
++}
++
++/*
++ * test if the @h_sb is real-readonly.
++ */
++int au_test_def_rr(struct super_block *h_sb)
++{
++	switch (h_sb->s_magic) {
++#ifdef CONFIG_AUFS_RR_SQUASHFS
++	case SQUASHFS_MAGIC_LZMA:
++	case SQUASHFS_MAGIC:
++	case SQUASHFS_MAGIC_LZMA_SWAP:
++	case SQUASHFS_MAGIC_SWAP:
++		return 1; /* real readonly */
++#endif
++
++#if defined(CONFIG_ISO9660_FS) || defined(CONFIG_ISO9660_FS_MODULE)
++	case ISOFS_SUPER_MAGIC:
++		return 1;
++#endif
++
++#if defined(CONFIG_CRAMFS) || defined(CONFIG_CRAMFS_MODULE)
++	case CRAMFS_MAGIC:
++		return 1;
++#endif
++
++#if defined(CONFIG_ROMFS_FS) || defined(CONFIG_ROMFS_FS_MODULE)
++	case ROMFS_MAGIC:
++		return 1;
++#endif
++
++	default:
++		return 0;
++	}
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * test if two hidden_dentries have overlapping branches.
++ */
++static int do_test_overlap(struct super_block *sb, struct dentry *h_d1,
++			   struct dentry *h_d2)
++{
++	struct dentry *d;
++
++	LKTRTrace("%.*s, %.*s\n", AuDLNPair(h_d1), AuDLNPair(h_d2));
++
++	d = au_test_subdir(h_d1, h_d2);
++	if (unlikely(d)) {
++		AuDbgDentry(h_d1);
++		AuDbgDentry(h_d2);
++	}
++	return !!d;
++}
++
++static int test_overlap_loopback(struct super_block *sb, struct dentry *h_d1,
++				 struct dentry *h_d2)
++{
++#if defined(CONFIG_BLK_DEV_LOOP) || defined(CONFIG_BLK_DEV_LOOP_MODULE)
++	struct inode *h_inode;
++	struct loop_device *l;
++
++	LKTRTrace("%.*s, %.*s\n", AuDLNPair(h_d1), AuDLNPair(h_d2));
++	AuDbgDentry(h_d1);
++	AuDbgDentry(h_d2);
++	AuDbgSb(h_d1->d_sb);
++	AuDbgSb(h_d2->d_sb);
++
++	h_inode = h_d1->d_inode;
++	if (MAJOR(h_inode->i_sb->s_dev) != LOOP_MAJOR)
++		return 0;
++
++	l = h_inode->i_sb->s_bdev->bd_disk->private_data;
++	h_d1 = l->lo_backing_file->f_dentry;
++	/* h_d1 can be local NFS. in this case aufs cannot detect the loop */
++	AuDbgDentry(h_d1);
++	AuDbgDentry(h_d2);
++	AuDbgSb(h_d1->d_sb);
++	AuDbgSb(h_d2->d_sb);
++	if (unlikely(h_d1->d_sb == sb))
++		return 1;
++	return do_test_overlap(sb, h_d1, h_d2);
++#else
++	return 0;
++#endif
++}
++
++static int test_overlap(struct super_block *sb, struct dentry *h_d1,
++			struct dentry *h_d2)
++{
++	LKTRTrace("d1 %.*s, d2 %.*s\n", AuDLNPair(h_d1), AuDLNPair(h_d2));
++
++	if (unlikely(h_d1 == h_d2)) {
++		AuDbgDentry(h_d1);
++		AuDbgDentry(h_d2);
++		return 1;
++	}
++	return do_test_overlap(sb, h_d1, h_d2)
++		|| do_test_overlap(sb, h_d2, h_d1)
++		|| test_overlap_loopback(sb, h_d1, h_d2)
++		|| test_overlap_loopback(sb, h_d2, h_d1);
++}
++
++/* ---------------------------------------------------------------------- */
++
++static int au_br_init_wh(struct super_block *sb, aufs_bindex_t bindex,
++			 struct au_branch *br, int new_perm,
++			 struct dentry *h_root, struct vfsmount *h_mnt)
++{
++	int err, old_perm;
++	struct inode *h_dir;
++	struct au_wbr *wbr;
++
++	LKTRTrace("b%d, new_perm %d\n", bindex, new_perm);
++	SiMustWriteLock(sb);
++
++	wbr = br->br_wbr;
++	h_dir = h_root->d_inode;
++	old_perm = br->br_perm;
++	mutex_lock_nested(&h_dir->i_mutex, AuLsc_I_PARENT);
++	if (wbr)
++		wbr_wh_write_lock(wbr);
++	br->br_perm = new_perm;
++	err = au_wh_init(h_root, br, h_mnt, sb, bindex);
++	br->br_perm = old_perm;
++	if (wbr)
++		wbr_wh_write_unlock(wbr);
++	mutex_unlock(&h_dir->i_mutex);
++	if (!err && wbr && !au_br_writable(new_perm)) {
++		AuDebugOn(wbr->wbr_whbase);
++		AuDebugOn(wbr->wbr_plink);
++		AuDebugOn(wbr->wbr_tmp);
++		kfree(wbr);
++		br->br_wbr = NULL;
++	}
++
++	AuTraceErr(err);
++	return err;
++}
++
++/* ---------------------------------------------------------------------- */
++
++/*
++ * returns a newly allocated branch. @new_nbranch is a number of branches
++ * after adding a branch.
++ */
++static struct au_branch *alloc_addbr(struct super_block *sb, int new_nbranch,
++				     int perm)
++{
++	struct au_branch **branchp, *add_branch;
++	int sz;
++	void *p;
++	struct dentry *root;
++	struct inode *inode;
++	struct au_hinode *hinodep;
++	struct au_hdentry *hdentryp;
++
++	LKTRTrace("new_nbranch %d\n", new_nbranch);
++	SiMustWriteLock(sb);
++	root = sb->s_root;
++	DiMustWriteLock(root);
++	inode = root->d_inode;
++	IiMustWriteLock(inode);
++
++	add_branch = kmalloc(sizeof(*add_branch), GFP_NOFS);
++	if (unlikely(!add_branch))
++		goto out;
++	add_branch->br_wbr = NULL;
++	if (au_br_writable(perm)) {
++		add_branch->br_wbr = kmalloc(sizeof(*add_branch->br_wbr),
++					     GFP_NOFS);
++		if (unlikely(!add_branch->br_wbr))
++			goto out_br;
++	}
++
++	sz = sizeof(*branchp) * (new_nbranch - 1);
++	if (unlikely(!sz))
++		sz = sizeof(*branchp);
++	p = au_sbi(sb)->si_branch;
++	branchp = au_kzrealloc(p, sz, sizeof(*branchp) * new_nbranch, GFP_NOFS);
++	if (unlikely(!branchp))
++		goto out_wbr;
++	au_sbi(sb)->si_branch = branchp;
++
++	sz = sizeof(*hdentryp) * (new_nbranch - 1);
++	if (unlikely(!sz))
++		sz = sizeof(*hdentryp);
++	p = au_di(root)->di_hdentry;
++	hdentryp = au_kzrealloc(p, sz, sizeof(*hdentryp) * new_nbranch,
++				GFP_NOFS);
++	if (unlikely(!hdentryp))
++		goto out_wbr;
++	au_di(root)->di_hdentry = hdentryp;
++
++	sz = sizeof(*hinodep) * (new_nbranch - 1);
++	if (unlikely(!sz))
++		sz = sizeof(*hinodep);
++	p = au_ii(inode)->ii_hinode;
++	hinodep = au_kzrealloc(p, sz, sizeof(*hinodep) * new_nbranch, GFP_NOFS);
++	if (unlikely(!hinodep))
++		goto out_wbr;
++	au_ii(inode)->ii_hinode = hinodep;
++	return add_branch; /* success */
++
++ out_wbr:
++	kfree(add_branch->br_wbr);
++ out_br:
++	kfree(add_branch);
++ out:
++	AuTraceErr(-ENOMEM);
++	return ERR_PTR(-ENOMEM);
++}
++
++/*
++ * test if the branch permission is legal or not.
++ */
++static int test_br(struct super_block *sb, struct inode *inode, int brperm,
++		   char *path)
++{
++	int err;
++
++	err = 0;
++	if (unlikely(au_br_writable(brperm) && IS_RDONLY(inode))) {
++		AuErr("write permission for readonly fs or inode, %s\n", path);
++		err = -EINVAL;
++	}
++
++	AuTraceErr(err);
++	return err;
++}
++
++static int au_unsupported_fs(struct super_block *sb)
++{
++	return sb->s_magic == PROC_SUPER_MAGIC
++#ifdef SYSFS_MAGIC
++		|| sb->s_magic == SYSFS_MAGIC
++#endif
++		|| !strcmp(au_sbtype(sb), "unionfs");
++}
++
++/*
++ * returns:
++ * 0: success, the caller will add it
++ * plus: success, it is already unified, the caller should ignore it
++ * minus: error
++ */
++static int test_add(struct super_block *sb, struct au_opt_add *add, int remount)
++{
++	int err;
++	struct dentry *root;
++	struct inode *inode, *h_inode;
++	aufs_bindex_t bend, bindex;
++
++	LKTRTrace("%s, remo%d\n", add->path, remount);
++
++	root = sb->s_root;
++	bend = au_sbend(sb);
++	if (unlikely(bend >= 0
++		     && au_find_dbindex(root, add->nd.path.dentry) >= 0)) {
++		err = 1;
++		if (!remount) {
++			err = -EINVAL;
++			AuErr("%s duplicated\n", add->path);
++		}
++		goto out;
++	}
++
++	err = -ENOSPC; /* -E2BIG; */
++	if (unlikely(AUFS_BRANCH_MAX <= add->bindex
++		     || AUFS_BRANCH_MAX - 1 <= bend)) {
++		AuErr("number of branches exceeded %s\n", add->path);
++		goto out;
++	}
++
++	err = -EDOM;
++	if (unlikely(add->bindex < 0 || bend + 1 < add->bindex)) {
++		AuErr("bad index %d\n", add->bindex);
++		goto out;
++	}
++
++	inode = add->nd.path.dentry->d_inode;
++	AuDebugOn(!inode || !S_ISDIR(inode->i_mode));
++	err = -ENOENT;
++	if (unlikely(!inode->i_nlink)) {
++		AuErr("no existence %s\n", add->path);
++		goto out;
++	}
++
++	err = -EINVAL;
++	if (unlikely(inode->i_sb == sb)) {
++		AuErr("%s must be outside\n", add->path);
++		goto out;
++	}
++
++	if (unlikely(au_test_nested(inode->i_sb))) {
++		AuErr("nested " AUFS_NAME " %s\n", add->path);
++		goto out;
++	}
++
++	if (unlikely(au_unsupported_fs(inode->i_sb))) {
++		AuErr("unsupported filesystem, %s\n", add->path);
++		goto out;
++	}
++
++	if (unlikely(au_test_unsupported_nfs(inode->i_sb))) {
++		AuErr(AuNoNfsBranchMsg " %s\n", add->path);
++		goto out;
++	}
++
++	if (unlikely(au_test_unsupported_nfs4(inode->i_sb))) {
++		AuErr(AuNoNfsv4BranchMsg " %s\n", add->path);
++		goto out;
++	}
++
++	err = test_br(sb, add->nd.path.dentry->d_inode, add->perm, add->path);
++	if (unlikely(err))
++		goto out;
++
++	if (bend < 0)
++		return 0; /* success */
++
++	err = -EINVAL;
++	for (bindex = 0; bindex <= bend; bindex++)
++		if (unlikely(test_overlap(sb, add->nd.path.dentry,
++					  au_h_dptr(root, bindex)))) {
++			AuErr("%s is overlapped\n", add->path);
++			goto out;
++		}
++
++	err = 0;
++	h_inode = au_h_dptr(root, 0)->d_inode;
++	if (unlikely(au_opt_test(au_mntflags(sb), WARN_PERM)
++		     && ((h_inode->i_mode & S_IALLUGO)
++			 != (inode->i_mode & S_IALLUGO)
++			 || h_inode->i_uid != inode->i_uid
++			 || h_inode->i_gid != inode->i_gid)))
++		AuWarn("uid/gid/perm %s %u/%u/0%o, %u/%u/0%o\n",
++		       add->path,
++		       inode->i_uid, inode->i_gid, (inode->i_mode & S_IALLUGO),
++		       h_inode->i_uid, h_inode->i_gid,
++		       (h_inode->i_mode & S_IALLUGO));
++
++ out:
++	AuTraceErr(err);
++	return err;
++}
++
++static int au_wbr_init(struct au_branch *br, struct super_block *sb,
++		       int perm, struct path *path)
++{
++	int err;
++	struct au_wbr *wbr;
++
++	AuTraceEnter();
++	wbr = br->br_wbr;
++	AuDebugOn(!wbr);
++
++	au_rw_init_nolock(&wbr->wbr_wh_rwsem);
++	memset(wbr->wbr_wh, 0, sizeof(wbr->wbr_wh));
++	atomic_set(&wbr->wbr_wh_running, 0);
++	wbr->wbr_bytes = 0;
++
++	err = au_br_init_wh(sb, /*bindex*/-1, br, perm,
++			    path->dentry, path->mnt);
++
++	AuTraceErr(err);
++	return err;
++}
++
++static int au_br_init(struct au_branch *br, struct super_block *sb,
++		      struct au_opt_add *add)
++{
++	int err;
++	unsigned int mnt_flags;
++
++	AuTraceEnter();
++
++	err = 0;
++	br->br_mnt = NULL;
++	br->br_xino.xi_file = NULL;
++	mutex_init(&br->br_xino.xi_nondir_mtx);
++	atomic_set(&br->br_xino_running, 0);
++	atomic_set(&br->br_count, 0);
++
++	if (au_br_writable(add->perm)) {
++		err = au_wbr_init(br, sb, add->perm, &add->nd.path);
++		if (unlikely(err))
++			goto out;
++	}
++
++	br->br_mnt = mntget(add->nd.path.mnt);
++	mnt_flags = au_mntflags(sb);
++	if (au_opt_test(mnt_flags, XINO)) {
++		err = au_xino_br(sb, br, add->nd.path.dentry->d_inode->i_ino,
++				 au_sbr(sb, 0)->br_xino.xi_file, /*do_test*/1);
++		if (unlikely(err)) {
++			AuDebugOn(br->br_xino.xi_file);
++			goto out;
++		}
++#if 0 /* reserved for future use */
++	} else if (au_opt_test(mnt_flags, XINODIR)) {
++		err = au_xinodir_br(sb, br, add->nd.path.dentry->d_inode->i_ino,
++				    /*do_test*/1);
++		if (unlikely(err)) {
++			AuDebugOn(br->br_xino.xi_file);
++			goto out;
++		}
++#endif
++	}
++
++	br->br_id = au_new_br_id(sb);
++	br->br_perm = add->perm;
++	br->br_xino_upper = AUFS_XINO_TRUNC_INIT;
++	sysaufs_br_init(br);
++	br->br_generation = au_sigen(sb);
++	/* smp_mb(); */ /* atomic_set */
++
++ out:
++	AuTraceErr(err);
++	return err;
++}
++
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list