commit dd999b0350b06e3e5325e4d47cb8b362f8c8a254
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Sun May 27 22:37:17 2007 -0400
comments for odf_lookup functions
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 9bbd9cf..b30774f 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, struct dentry
*dentry, int flags)
/* 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,
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs