zfs-linux / zfs

Native ZFS for Linux
http://wiki.github.com/behlendorf/zfs/
Other
56 stars 2 forks source link

date issue : year of file system creation is wrong. #86

Closed ganeshjagtap closed 13 years ago

ganeshjagtap commented 13 years ago

root@fedora14-43:~ 09:26 PM zpool create tank sdb1 root@fedora14-43:~ 09:27 PM zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT tank 11.9G 70K 11.9G 0% 1.00x ONLINE - root@fedora14-43:~ 09:27 PM zfs create tank/fs root@fedora14-43:~ 09:27 PM ls -l /tank/ total 0 drwxr-xr-x. 1 root root 0 Jan 1 1970 fs root@fedora14-43:~ 09:27 PM

ganeshjagtap commented 13 years ago

date is 1970. It should be current date. drwxr-xr-x. 1 root root 0 Jan 1 1970 fs

mitra commented 13 years ago

won't fix in GA minor issue. After the first ls the date is reported correctly.

ganeshjagtap commented 13 years ago

Possible fix ZFS diff

 
$ git diff
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
index 41c47b3..bdfe793 100644
--- a/module/zfs/zfs_znode.c
+++ b/module/zfs/zfs_znode.c
@@ -731,6 +731,46 @@ zfs_inode_alloc(zfsvfs_t *zfsvfs, znode_t *zp, dmu_buf_t *db,
    unlock_new_inode(inode);
 }

+void vp_inode_update(vnode_t *vp) 
+{
+   struct inode    *inode;
+   znode_t *zp = VTOZ(vp) ;
+   uint32_t    blksize;
+   zfsvfs_t    *zfsvfs = zp->z_zfsvfs;
+   uint64_t    atime[2], mtime[2], ctime[2];
+
+   inode = LZFS_VTOI(vp);
+
+   spin_lock(&inode->i_lock);
+   inode->i_uid = zp->z_uid;
+   inode->i_gid = zp->z_gid;
+   inode->i_nlink = zp->z_links;
+   inode->i_mode = zp->z_mode;
+   inode->i_blkbits = SPA_MINBLOCKSHIFT;
+   i_size_write(inode, zp->z_size);
+   dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &blksize, 
+           (u_longlong_t *)&inode->i_blocks);
+   spin_unlock(&inode->i_lock);
+
+   sa_lookup(zp->z_sa_hdl, SA_ZPL_ATIME(zfsvfs), &atime, 16);
+   sa_lookup(zp->z_sa_hdl, SA_ZPL_MTIME(zfsvfs), &mtime, 16);
+   sa_lookup(zp->z_sa_hdl, SA_ZPL_CTIME(zfsvfs), &ctime, 16);
+   /* TODO  (PRASAD) (Neependra Merging)
+    *  modify inode number of blocks 
+    *  modify inode block size
+    */
+   ZFS_TIME_DECODE(&inode->i_atime, atime);
+   ZFS_TIME_DECODE(&inode->i_mtime, mtime);
+   ZFS_TIME_DECODE(&inode->i_ctime, ctime);
+   /*      Need a way to update mtime and time
+       ZFS_TIME_DECODE(&inode->i_mtime, zp->zp_mtime);
+       ZFS_TIME_DECODE(&inode->i_ctime, zp->zp_ctime);
+    */
+   inode->i_generation = zp->z_gen;
+
+}
+EXPORT_SYMBOL(vp_inode_update);
+

LZFS diff

 

diff --git a/module/lzfs_super.c b/module/lzfs_super.c
index 4af3398..9122731 100644
--- a/module/lzfs_super.c
+++ b/module/lzfs_super.c
@@ -61,6 +61,7 @@ extern int zfs_umount(vfs_t *vfsp, int fflags, cred_t *cr);
 extern int zfs_statvfs(vfs_t *vfsp, struct statvfs64 *statp);
 extern void lzfs_zfsctl_create(vfs_t *);
 extern void lzfs_zfsctl_destroy(vfs_t *);
+extern void vp_inode_update(vnode_t *vp);

 /\* TODO
- Following checking needs part of lzfs/spl configuration step.
  @@ -293,8 +294,12 @@ lzfs_fill_super(struct super_block *sb, void *data, int silent)
      printk(KERN_WARNING "chkneep4: %s\n", **FUNCTION**);
      goto mount_failed;
  }
  -   

  sb->s_root = root_dentry;
  -   
  -   vp_inode_update(root_vnode);
    +

  if (!strchr((char *) data, '@')) {
      lzfs_zfsctl_create(vfsp);