commit 5b591789ea292843ca35b726aca7780a27eaaafa
Merge: ae92b77... 3f58874...
Author: Erez_Zadok <[EMAIL PROTECTED]>
Date: Mon May 28 23:28:41 2007 -0400
Merge branch 'master' of story:/home/git/unionfs-odf
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index
d4a89fac89b1f4627455979038b22750d18de7c3..83b006d5523df09259c9b8bd247cb68214174d15
100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -183,6 +183,13 @@ find:
if (err || buf->mode != RD_CACHE_ODF || !buf->filp || whiteout)
goto out;
+ /* Ideally we would want all entries we find here to be in the
+ * odf and have a persisten inode. However it is possible for the
+ * entries not to be in the odf yet, and thus not have a valid odf
+ * inode number. We could have created an entry in the odf at this
+ * point, but since we do not have a unionfs dentry here we wouldn't
+ * be able to check for hardlinks
+ */
if (odf_dentry)
ino = odf_dentry->d_inode->i_ino;
err = odf_write_dirent(buf->filp, name, namelen, ino, d_type);
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index
9bbd9cfc47f1ee112b26bd1e695919d16193a0cc..aea6a09ce3626aa80c8928c8869783a291ac9a38
100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -881,20 +881,44 @@ out:
}
/*
- * Lookup an entry in the odf, and create it if necessary
- * Returns a an odf_dentry_info containing whiteout and
- * opaqueness information. Also handles hard links.
- * If no flags are set and lookup fails, NULL is returned
- * The function puts the dentry's odf_info and NULL's it
- * Flags:
- * - None set: lookup does not create any new entries
+ * ODF lookup - There are two wrapper functions for looking up entries
+ * in the ODF: odf_lookup and and odf_lookup_name. Apart from looking up
+ * entries they both can create dirs, files or whiteouts if the requested
+ * file does not yet exist in the odf.
+ *
+ * These functions should only be used for looking entries in /odf/ns.
+ *
+ * The ODF_LOOKUP_ flags are applicable to both functions:
+ *
+ * - no flags: plain lookup, does not change the ODF state
+ * - ODF_LOOKUP_RMV_WH: if lookup finds a whiteout, it removes it
+ *
+ * The rest of the flags apply if the requested entry is not found or
+ * a whiteout was found and removed using the ODF_LOOKUP_RMV_WH flag
+ *
* - ODF_LOOKUP_FILE: create a file entry if lookup fails
* - ODF_LOOKUP_DIR: create a dir if lookup fails
- * - ODF_LOOKUP_RMV_WH: if lookup returns a wh, remove it
- * (useful for create where we want to rmv wh's)
* - ODF_LOOKUP_OPQ: if a dir is created, set it opaque (branch 0)
* - ODF_LOOKUP_WH: create a whiteout
- * - ODF_LOOKUP_LOCKED: dont lock parent and ic (already locked from
caller)
+ */
+
+/* odf_lookup: This function should be used whenever we have a unionfs
+ * dentry and want to find its entry in the ODF. Before doing the lookup
+ * it checks for hardlinks and tries to lazily build up the links in the
+ * odf.
+ *
+ * If the given target unionfs dentry already has an odf dentry in its
+ * odf_dentry_info, it is dput before the lookup.
+ *
+ * Upon success the given dentry's odf_dentry_info struct is filled with
+ * the odf dentry, opaquness and whiteout flag.
+ *
+ * If the entry is not found in the odf, 0 is returned but the odf_dentry
+ * in the odf_dentry_info struct is set to NULL.
+ *
+ * @parent: unionfs dir dentry
+ * @dentry: unionfs dentry that we want to find its odf dentry
+ * @flags: ODF_LOOKUP_ flags (see above)
*/
int odf_lookup(struct dentry *parent, struct dentry *dentry, int flags)
{
@@ -956,7 +980,6 @@ int odf_lookup(struct dentry *parent, st
/* XXX: Leave this out until Jeff's modifications to path_lookup
__check_link_copyup(link_file, dentry, bstart);
__link_add_dirent(link_file, dentry);
- flags |= ODF_LOOKUP_LINK;
*/
}
@@ -975,11 +998,43 @@ out:
filp_close(link_file, NULL);
return err;
}
+
+/* odf_lookup_name: This function should be used whenever we don't have a
+ * unionfs dentry, but want to lookup a name in the odf. It should never
+ * be used to create entries in the odf, apart from whiteouts, since it
+ * does not handle hardlinks.
+ *
+ * If a matching dentry is found in the odf that is not a wh, it is returned
+ * If a whiteout dentry is found, NULL is returned
+ * If the entry is not found, -ENOENT is returned
+ *
+ * @parent: unionfs dir dentry
+ * @name: name to look for
+ * @len: length of the name
+ * @flags: ODF_LOOKUP_ flags (see above)
+ */
struct dentry *odf_lookup_name(struct dentry *parent, const char *name, int
len, int flags)
{
return __odf_lookup(parent, NULL, name, len, flags, NULL);
}
+/* __odf_lookup:looks up an entry in the odf, creates new entries if
+ * required and handles hardlinks
+ *
+ * @parent: unionfs dir dentry
+ * @target: unionfs target dentry. If not NULL, lookup will update its
+ * odf_dentry_info if an entry is found, or else NULLify it.
+ * Its name is not used for the lookup, as it can be NULL
+ * @name: the name to look for
+ * @len: name length
+ * @flags: ODF_LOOKUP_ flags (see above)
+ * @link: an odf dentry that's the odf entry of one the target dentry's
+ * links. If this is not NULL, lookup will make sure the looked
+ * up dentry is linked to the given link in the odf
+ *
+ * XXX: whether link should be an odf or uniofs dentry should be
+ * decided when hardlinks are actually implemented
+ */
struct dentry *__odf_lookup(struct dentry *parent,
struct dentry *target,
const char *name, int len, int flags,
@@ -1040,7 +1095,7 @@ retry:
else if (flags & ODF_LOOKUP_FILE) {
current->fsuid = 0;
current->fsgid = 0;
- err = vfs_create(odf_i_dir, odf_dentry, S_IRWXUGO, 0 );
+ err = vfs_create(odf_i_dir, odf_dentry, S_IRWXUGO, 0);
}
else if (flags & ODF_LOOKUP_WH) {
current->fsuid = 0;
@@ -1101,6 +1156,11 @@ retry:
odf_dentry = NULL;
}
}
+ /* We return ENOENT if no entry is found, so the caller can
+ * distinguish between an entry not being in the odf and an
+ * entry that is in the odf but is a whiteout, (where NULL is
+ * is returned)
+ */
else if (!odf_dentry)
odf_dentry = ERR_PTR(-ENOENT);
out:
@@ -1186,7 +1246,7 @@ struct dentry *odf_ic_dentry(struct odf_
goto out;
}
if (!ret->d_inode) {
- err = vfs_create(dirs[3]->d_inode, ret, S_IRWXUGO, 0 );
+ err = vfs_create(dirs[3]->d_inode, ret, S_IRWXUGO, 0);
if (err)
dput(ret);
}
@@ -1617,7 +1677,7 @@ int odf_write_sb_data(struct odf_sb_info
}
}
else {
- err = vfs_create(d_content->d_parent->d_inode, d_content,
S_IRWXUGO, NULL );
+ err = vfs_create(d_content->d_parent->d_inode, d_content,
S_IRWXUGO, NULL);
if (err)
goto out;
}
diff --git a/fs/unionfs/odf.h b/fs/unionfs/odf.h
index
9a3c25d30699ed37a6cb29acbe067c5ecfce18e9..787e4f1ea84fabf29f38918055b779b95e84117e
100644
--- a/fs/unionfs/odf.h
+++ b/fs/unionfs/odf.h
@@ -19,14 +19,12 @@ #define ODF_BRANCH_PATH 255
#define ODF_OPTIONS_LEN 255
#define ODF_INAME_LEN 10
-/* Lookup flags (what to create if lookup fails) */
-#define ODF_LOOKUP_FILE 1
-#define ODF_LOOKUP_DIR 2
-#define ODF_LOOKUP_RMV_WH 4
-#define ODF_LOOKUP_OPQ 8
-#define ODF_LOOKUP_WH 16
-#define ODF_LOOKUP_LOCKED 32
-#define ODF_LOOKUP_LINK 64
+/* Lookup flags */
+#define ODF_LOOKUP_RMV_WH 0x01
+#define ODF_LOOKUP_FILE 0x02
+#define ODF_LOOKUP_DIR 0x04
+#define ODF_LOOKUP_OPQ 0x08
+#define ODF_LOOKUP_WH 0x10
/* Unlink/Remove flags */
#define ODF_RMV_WH 1
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs