[Tux3] [PATCH] fix mtime support by adding tux3_setattr

Shapor Naghibzadeh shapor at gmail.com
Thu Dec 11 18:13:25 PST 2008


This patch implements setattr fileop for Tux3.  Tux3 now stores the
mtime properly and persistently, which I tested under UML.

I'm updating the MTIME_BIT in tuxnode->present every time, before
calling inode_setattr, which marks the inode dirty.  I considered
twiddling the MTIME_BIT afterwards, but I wasn't sure if that was safe
since the inode was already set dirty (and could possibly get
flushed?), so I was forced to check if the mtime/ctime was changing.

Thanks to Daniel for the excellent instructions:
http://mailman.tux3.org/pipermail/tux3/2008-November/000380.html
Now we just need a git repo that works :)

diff -rup linux-2.6.26.5.orig/fs/tux3/inode.c linux-2.6.26.5/fs/tux3/inode.c
--- linux-2.6.26.5.orig/fs/tux3/inode.c 2008-12-11 17:42:16.000000000 -0800
+++ linux-2.6.26.5/fs/tux3/inode.c      2008-12-11 17:50:29.000000000 -0800
@@ -218,7 +218,7 @@ static const struct file_operations tux_
 static const struct inode_operations tux_file_iops = {
 //     .truncate       = ext4_truncate,
 //     .permission     = ext4_permission,
-//     .setattr        = ext4_setattr,
+       .setattr        = tux3_setattr,
 //     .getattr        = ext4_getattr
 #ifdef CONFIG_EXT4DEV_FS_XATTR
 //     .setxattr       = generic_setxattr,
@@ -324,4 +324,22 @@ struct inode *tux3_iget(struct super_blo
        unlock_new_inode(inode);
        return inode;
 }
+
+int tux3_setattr(struct dentry *dentry, struct iattr *iattr)
+{
+       struct inode *inode = dentry->d_inode;
+       tuxnode_t *tuxnode = tux_inode(inode);
+       int error;
+
+       error = inode_change_ok(inode, iattr);
+       if (error)
+               return error;
+       if (timespec_equal(iattr->ia_valid & ATTR_MTIME ?
&iattr->ia_mtime : &inode->i_mtime,
+                          iattr->ia_valid & ATTR_CTIME ?
&iattr->ia_ctime : &inode->i_ctime))
+               tuxnode->present &= ~MTIME_BIT;
+       else
+               tuxnode->present |= MTIME_BIT;
+
+       return inode_setattr(inode, iattr);
+}
 #endif /* !__KERNEL__ */
diff -rup linux-2.6.26.5.orig/fs/tux3/tux3.h linux-2.6.26.5/fs/tux3/tux3.h
--- linux-2.6.26.5.orig/fs/tux3/tux3.h  2008-12-11 17:42:16.000000000 -0800
+++ linux-2.6.26.5/fs/tux3/tux3.h       2008-12-11 17:36:37.000000000 -0800
@@ -636,6 +636,7 @@ void tux3_clear_inode(struct inode *inod
 int tux3_write_inode(struct inode *inode, int do_sync);
 struct inode *tux_create_inode(struct inode *dir, int mode);
 struct inode *tux3_iget(struct super_block *sb, inum_t inum);
+int tux3_setattr(struct dentry *dentry, struct iattr *iattr);

 /* xattr.c */
 int xcache_dump(struct inode *inode);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tux3.setattr.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://phunq.net/pipermail/tux3/attachments/20081211/9b5d25ee/attachment.bin>
-------------- next part --------------
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3


More information about the Tux3 mailing list