head	1.1;
access;
symbols
	LKML-branch:1.1.0.2;
locks; strict;
comment	@# @;


1.1
date	2006.10.24.06.14.17;	author jsipek;	state dead;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2006.10.24.06.14.17;	author jsipek;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2006.11.07.06.13.33;	author jsipek;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2006.11.28.08.30.13;	author jsipek;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2006.12.01.02.36.12;	author jsipek;	state Exp;
branches;
next	1.1.2.5;

1.1.2.5
date	2006.12.03.21.49.41;	author jsipek;	state Exp;
branches;
next	1.1.2.6;

1.1.2.6
date	2006.12.11.14.23.59;	author jsipek;	state Exp;
branches;
next	1.1.2.7;

1.1.2.7
date	2007.01.21.23.59.13;	author jsipek;	state Exp;
branches;
next	;


desc
@@


1.1
log
@file fanout was initially added on branch LKML-branch.
@
text
@@


1.1.2.1
log
@Move unionfs specific bits into a subdir
@
text
@a0 206
Unionfs: Helper macros/inlines

From: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>

This patch contains many macros and inline functions used thoughout Unionfs.

Signed-off-by: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>
Signed-off-by: David Quigley <dquigley@@fsl.cs.sunysb.edu>
Signed-off-by: Erez Zadok <ezk@@cs.sunysb.edu>

diff -r daf7db274c6d fs/unionfs/fanout.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/unionfs/fanout.h	Sat Oct 07 00:36:38 2006 -0400
@@@@ -0,0 +1,192 @@@@
+/*
+ * Copyright (c) 2003-2006 Erez Zadok
+ * Copyright (c) 2003-2006 Charles P. Wright
+ * Copyright (c) 2005-2006 Josef Sipek
+ * Copyright (c) 2005      Arun M. Krishnakumar
+ * Copyright (c) 2004-2006 David P. Quigley
+ * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
+ * Copyright (c) 2003      Puja Gupta
+ * Copyright (c) 2003      Harikesavan Krishnan
+ * Copyright (c) 2003-2006 Stony Brook University
+ * Copyright (c) 2003-2006 The Research Foundation of State University of New York
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _FANOUT_H_
+#define _FANOUT_H_
+
+/* Inode to private data */
+static inline struct unionfs_inode_info *itopd(const struct inode *inode)
+{
+	return
+	    &(container_of(inode, struct unionfs_inode_container, vfs_inode)->
+	      info);
+}
+
+#define itohi_ptr(ino) (itopd(ino)->uii_inode)
+#define ibstart(ino) (itopd(ino)->b_start)
+#define ibend(ino) (itopd(ino)->b_end)
+
+/* Superblock to private data */
+#define stopd(super) ((struct unionfs_sb_info *)(super)->s_fs_info)
+#define stopd_lhs(super) ((super)->s_fs_info)
+#define sbstart(sb) 0
+#define sbend(sb) stopd(sb)->b_end
+#define sbmax(sb) (stopd(sb)->b_end + 1)
+
+/* File to private Data */
+#define ftopd(file) ((struct unionfs_file_info *)((file)->private_data))
+#define ftopd_lhs(file) ((file)->private_data)
+#define ftohf_ptr(file)  (ftopd(file)->ufi_file)
+#define fbstart(file) (ftopd(file)->b_start)
+#define fbend(file) (ftopd(file)->b_end)
+
+/* File to hidden file. */
+static inline struct file *ftohf(struct file *f)
+{
+	return ftopd(f)->ufi_file[fbstart(f)];
+}
+
+static inline struct file *ftohf_index(const struct file *f, int index)
+{
+	return ftopd(f)->ufi_file[index];
+}
+
+static inline void set_ftohf_index(struct file *f, int index, struct file *val)
+{
+	ftopd(f)->ufi_file[index] = val;
+}
+
+static inline void set_ftohf(struct file *f, struct file *val)
+{
+	ftopd(f)->ufi_file[fbstart(f)] = val;
+}
+
+/* Inode to hidden inode. */
+static inline struct inode *itohi(const struct inode *i)
+{
+	return itopd(i)->uii_inode[ibstart(i)];
+}
+
+static inline struct inode *itohi_index(const struct inode *i, int index)
+{
+	return itopd(i)->uii_inode[index];
+}
+
+static inline void set_itohi_index(struct inode *i, int index,
+				   struct inode *val)
+{
+	itopd(i)->uii_inode[index] = val;
+}
+
+static inline void set_itohi(struct inode *i, struct inode *val)
+{
+	itopd(i)->uii_inode[ibstart(i)] = val;
+}
+
+/* Superblock to hidden superblock. */
+static inline struct super_block *stohs(const struct super_block *o)
+{
+	return stopd(o)->usi_data[sbstart(o)].sb;
+}
+
+static inline struct super_block *stohs_index(const struct super_block *o, int index)
+{
+	return stopd(o)->usi_data[index].sb;
+}
+
+static inline void set_stohs_index(struct super_block *o, int index,
+				   struct super_block *val)
+{
+	stopd(o)->usi_data[index].sb = val;
+}
+
+static inline void set_stohs(struct super_block *o, struct super_block *val)
+{
+	stopd(o)->usi_data[sbstart(o)].sb = val;
+}
+
+/* Branch count macros. */
+static inline int branch_count(struct super_block *o, int index)
+{
+	return atomic_read(&stopd(o)->usi_data[index].sbcount);
+}
+
+static inline void set_branch_count(struct super_block *o, int index, int val)
+{
+	atomic_set(&stopd(o)->usi_data[index].sbcount, val);
+}
+
+static inline void branchget(struct super_block *o, int index)
+{
+	atomic_inc(&stopd(o)->usi_data[index].sbcount);
+}
+
+static inline void branchput(struct super_block *o, int index)
+{
+	atomic_dec(&stopd(o)->usi_data[index].sbcount);
+}
+
+/* Dentry macros */
+static inline struct unionfs_dentry_info *dtopd(const struct dentry *dent)
+{
+	return dent->d_fsdata;
+}
+
+#define dtopd_lhs(dent) ((dent)->d_fsdata)
+#define dtopd_nocheck(dent) dtopd(dent)
+#define dbstart(dent) (dtopd(dent)->udi_bstart)
+#define set_dbstart(dent, val) do { dtopd(dent)->udi_bstart = val; } while(0)
+#define dbend(dent) (dtopd(dent)->udi_bend)
+#define set_dbend(dent, val) do { dtopd(dent)->udi_bend = val; } while(0)
+#define dbopaque(dent) (dtopd(dent)->udi_bopaque)
+#define set_dbopaque(dent, val) do { dtopd(dent)->udi_bopaque = val; } while (0)
+
+static inline void set_dtohd_index(struct dentry *dent, int index,
+				   struct dentry *val)
+{
+	dtopd(dent)->udi_dentry[index] = val;
+}
+
+static inline struct dentry *dtohd_index(const struct dentry *dent, int index)
+{
+	return dtopd(dent)->udi_dentry[index];
+}
+
+static inline struct dentry *dtohd(const struct dentry *dent)
+{
+	return dtopd(dent)->udi_dentry[dbstart(dent)];
+}
+
+static inline void set_dtohm_index(struct dentry *dent, int index,
+				   struct vfsmount *mnt)
+{
+	dtopd(dent)->udi_mnt[index] = mnt;
+}
+
+static inline struct vfsmount *dtohm_index(const struct dentry *dent, int index)
+{
+	return dtopd(dent)->udi_mnt[index];
+}
+
+static inline struct vfsmount *dtohm(const struct dentry *dent)
+{
+	return dtopd(dent)->udi_mnt[dbstart(dent)];
+}
+
+#define set_dtohd_index_nocheck(dent, index, val) set_dtohd_index(dent, index, val)
+#define dtohd_index_nocheck(dent, index) dtohd_index(dent, index)
+
+#define dtohd_ptr(dent) (dtopd(dent)->udi_dentry)
+
+#define dtohm_ptr(dent) (dtopd(dent)->udi_mnt)
+
+/* Macros for locking a dentry. */
+#define lock_dentry(d) down(&dtopd(d)->udi_sem)
+#define unlock_dentry(d) up(&dtopd(d)->udi_sem)
+#define verify_locked(d)
+
+#endif	/* _FANOUT_H */
@


1.1.2.2
log
@Git generates slightly different diffs - same information, just little
different
@
text
@d11 3
a13 5
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
new file mode 100644
index 0000000..2478675
--- /dev/null
+++ b/fs/unionfs/fanout.h
@


1.1.2.3
log
@Collapsed: struct_path-unionfs unionfs-fix-comments unionfs-kill-wrappers
@
text
@d14 3
a16 5

diff -r 272d8f8ec5df fs/unionfs/fanout.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/unionfs/fanout.h	Tue Nov 28 03:24:02 2006 -0500
@@@@ -0,0 +1,190 @@@@
d167 1
a167 1
+	dtopd(dent)->udi_path[index].dentry = val;
d172 1
a172 1
+	return dtopd(dent)->udi_path[index].dentry;
d177 1
a177 1
+	return dtohd_index(dent, dbstart(dent));
d183 1
a183 1
+	dtopd(dent)->udi_path[index].mnt = mnt;
d188 1
a188 1
+	return dtopd(dent)->udi_path[index].mnt;
d193 1
a193 1
+	return dtohm_index(dent,dbstart(dent));
d199 3
a201 1
+#define dtohp_ptr(dent) (dtopd(dent)->udi_path)
@


1.1.2.4
log
@Remove git crud & nicer makefile
@
text
@d11 4
@


1.1.2.5
log
@Collapsed macro patch into unionfs proper
@
text
@d11 1
a11 1
diff -r d1ab7df1e04f fs/unionfs/fanout.h
d13 2
a14 2
+++ b/fs/unionfs/fanout.h	Sun Dec 03 16:40:31 2006 -0500
@@@@ -0,0 +1,177 @@@@
d36 1
a36 1
+static inline struct unionfs_inode_info *UNIONFS_I(const struct inode *inode)
d38 3
a40 1
+	return container_of(inode, struct unionfs_inode_info, vfs_inode);
d43 3
a45 2
+#define ibstart(ino) (UNIONFS_I(ino)->bstart)
+#define ibend(ino) (UNIONFS_I(ino)->bend)
d48 2
a49 1
+#define UNIONFS_SB(super) ((struct unionfs_sb_info *)(super)->s_fs_info)
d51 2
a52 2
+#define sbend(sb) UNIONFS_SB(sb)->bend
+#define sbmax(sb) (UNIONFS_SB(sb)->bend + 1)
d55 5
a59 3
+#define UNIONFS_F(file) ((struct unionfs_file_info *)((file)->private_data))
+#define fbstart(file) (UNIONFS_F(file)->bstart)
+#define fbend(file) (UNIONFS_F(file)->bend)
d61 2
a62 2
+/* File to lower file. */
+static inline struct file *unionfs_lower_file(struct file *f)
d64 1
a64 1
+	return UNIONFS_F(f)->lower_files[fbstart(f)];
d67 1
a67 1
+static inline struct file *unionfs_lower_file_idx(const struct file *f, int index)
d69 1
a69 1
+	return UNIONFS_F(f)->lower_files[index];
d72 1
a72 1
+static inline void unionfs_set_lower_file_idx(struct file *f, int index, struct file *val)
d74 1
a74 1
+	UNIONFS_F(f)->lower_files[index] = val;
d77 1
a77 1
+static inline void unionfs_set_lower_file(struct file *f, struct file *val)
d79 1
a79 1
+	UNIONFS_F(f)->lower_files[fbstart(f)] = val;
d82 2
a83 2
+/* Inode to lower inode. */
+static inline struct inode *unionfs_lower_inode(const struct inode *i)
d85 1
a85 1
+	return UNIONFS_I(i)->lower_inodes[ibstart(i)];
d88 1
a88 1
+static inline struct inode *unionfs_lower_inode_idx(const struct inode *i, int index)
d90 1
a90 1
+	return UNIONFS_I(i)->lower_inodes[index];
d93 1
a93 1
+static inline void unionfs_set_lower_inode_idx(struct inode *i, int index,
d96 1
a96 1
+	UNIONFS_I(i)->lower_inodes[index] = val;
d99 1
a99 1
+static inline void unionfs_set_lower_inode(struct inode *i, struct inode *val)
d101 1
a101 1
+	UNIONFS_I(i)->lower_inodes[ibstart(i)] = val;
d104 2
a105 2
+/* Superblock to lower superblock. */
+static inline struct super_block *unionfs_lower_super(const struct super_block *sb)
d107 1
a107 1
+	return UNIONFS_SB(sb)->data[sbstart(sb)].sb;
d110 1
a110 1
+static inline struct super_block *unionfs_lower_super_idx(const struct super_block *sb, int index)
d112 1
a112 1
+	return UNIONFS_SB(sb)->data[index].sb;
d115 1
a115 1
+static inline void unionfs_set_lower_super_idx(struct super_block *sb, int index,
d118 1
a118 1
+	UNIONFS_SB(sb)->data[index].sb = val;
d121 1
a121 1
+static inline void unionfs_set_lower_super(struct super_block *sb, struct super_block *val)
d123 1
a123 1
+	UNIONFS_SB(sb)->data[sbstart(sb)].sb = val;
d127 1
a127 1
+static inline int branch_count(struct super_block *sb, int index)
d129 1
a129 1
+	return atomic_read(&UNIONFS_SB(sb)->data[index].sbcount);
d132 1
a132 1
+static inline void set_branch_count(struct super_block *sb, int index, int val)
d134 1
a134 1
+	atomic_set(&UNIONFS_SB(sb)->data[index].sbcount, val);
d137 1
a137 1
+static inline void branchget(struct super_block *sb, int index)
d139 1
a139 1
+	atomic_inc(&UNIONFS_SB(sb)->data[index].sbcount);
d142 1
a142 1
+static inline void branchput(struct super_block *sb, int index)
d144 1
a144 1
+	atomic_dec(&UNIONFS_SB(sb)->data[index].sbcount);
d148 1
a148 1
+static inline struct unionfs_dentry_info *UNIONFS_D(const struct dentry *dent)
d153 8
a160 6
+#define dbstart(dent) (UNIONFS_D(dent)->bstart)
+#define set_dbstart(dent, val) do { UNIONFS_D(dent)->bstart = val; } while(0)
+#define dbend(dent) (UNIONFS_D(dent)->bend)
+#define set_dbend(dent, val) do { UNIONFS_D(dent)->bend = val; } while(0)
+#define dbopaque(dent) (UNIONFS_D(dent)->bopaque)
+#define set_dbopaque(dent, val) do { UNIONFS_D(dent)->bopaque = val; } while (0)
d162 1
a162 1
+static inline void unionfs_set_lower_dentry_idx(struct dentry *dent, int index,
d165 1
a165 1
+	UNIONFS_D(dent)->lower_paths[index].dentry = val;
d168 1
a168 1
+static inline struct dentry *unionfs_lower_dentry_idx(const struct dentry *dent, int index)
d170 1
a170 1
+	return UNIONFS_D(dent)->lower_paths[index].dentry;
d173 1
a173 1
+static inline struct dentry *unionfs_lower_dentry(const struct dentry *dent)
d175 1
a175 1
+	return unionfs_lower_dentry_idx(dent, dbstart(dent));
d178 1
a178 1
+static inline void unionfs_set_lower_mnt_idx(struct dentry *dent, int index,
d181 1
a181 1
+	UNIONFS_D(dent)->lower_paths[index].mnt = mnt;
d184 1
a184 1
+static inline struct vfsmount *unionfs_lower_mnt_idx(const struct dentry *dent, int index)
d186 1
a186 1
+	return UNIONFS_D(dent)->lower_paths[index].mnt;
d189 1
a189 1
+static inline struct vfsmount *unionfs_lower_mnt(const struct dentry *dent)
d191 1
a191 1
+	return unionfs_lower_mnt_idx(dent,dbstart(dent));
d194 5
d200 2
a201 2
+#define lock_dentry(d)		down(&UNIONFS_D(d)->sem)
+#define unlock_dentry(d)	up(&UNIONFS_D(d)->sem)
@


1.1.2.6
log
@Folded unionfs-lkml-comments-jan
@
text
@d11 1
a11 1
diff -r fc178b30cc42 fs/unionfs/fanout.h
d13 1
a13 1
+++ b/fs/unionfs/fanout.h	Mon Dec 11 09:08:19 2006 -0500
d47 1
a47 1
+#define sbend(sb) (UNIONFS_SB(sb)->bend)
d56 1
a56 1
+static inline struct file *unionfs_lower_file(const struct file *f)
d121 1
a121 1
+static inline int branch_count(const struct super_block *sb, int index)
@


1.1.2.7
log
@A. Bunk's patch, more akpm comments, new copyright
@
text
@d11 3
a13 5
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
new file mode 100644
index 0000000..6fe5d3f
--- /dev/null
+++ b/fs/unionfs/fanout.h
d16 1
a16 1
+ * Copyright (c) 2003-2007 Erez Zadok
d18 1
a18 1
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
d24 2
a25 2
+ * Copyright (c) 2003-2007 Stony Brook University
+ * Copyright (c) 2003-2007 The Research Foundation of State University of New York
@


