Re: [PATCH 1/1] Unionfs: cache-coherency - dentries

From: Josef 'Jeff' Sipek
Date: Thu Sep 06 2007 - 12:44:22 EST


On Mon, Sep 03, 2007 at 07:39:48PM -0400, Josef 'Jeff' Sipek wrote:
...
> /*
> + * Determine if the lower inode objects have changed from below the unionfs
> + * inode. Return 1 if changed, 0 otherwise.
> + */
> +bool is_newer_lower(const struct dentry *dentry)
> +{
> + int bindex;
> + struct inode *inode;
> + struct inode *lower_inode;
> +
> + /* ignore if we're called on semi-initialized dentries/inodes */
> + if (!dentry || !UNIONFS_D(dentry))
> + return false;
> + inode = dentry->d_inode;
> + if (!inode || !UNIONFS_I(inode) ||
> + ibstart(inode) < 0 || ibend(inode) < 0)
> + return false;
> +
> + for (bindex = ibstart(inode); bindex <= ibend(inode); bindex++) {
> + lower_inode = unionfs_lower_inode_idx(inode, bindex);
> + if (!lower_inode)
> + continue;
> + /*
> + * We may want to apply other tests to determine if the
> + * lower inode's data has changed, but checking for changed
> + * ctime and mtime on the lower inode should be enough.
> + */
> + if (timespec_compare(&inode->i_mtime,
> + &lower_inode->i_mtime) < 0) {
> + printk("unionfs: new lower inode mtime "
> + "(bindex=%d, name=%s)\n", bindex,
> + dentry->d_name.name);
> + return true; /* mtime changed! */
> + }
> + if (timespec_compare(&inode->i_ctime,
> + &lower_inode->i_ctime) < 0) {
> + printk("unionfs: new lower inode ctime "
> + "(bindex=%d, name=%s)\n", bindex,
> + dentry->d_name.name);
> + return true; /* ctime changed! */
> + }
> + }
> + return true; /* default: lower is not newer */

This was a thinko, it should have returned false. I'll send an updated
patch for completeness.

Josef 'Jeff' Sipek.

--
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
- Albert Einstein
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/