Re: [PATCH] Btrfs: Add code to support file creation time.

2012-09-30 Thread Arne Jansen
On 07/04/12 13:04, Alexander Block wrote:
 On Wed, Jul 4, 2012 at 9:56 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.



 Well, how do users use this file creation time? There's no syscall and 
 there's
 no ioctl that exports this information. That xstat syscall hasn't been 
 accepted,
 so you can revise and repost the patch when you see it happens.
 In my opinion we should still include this patch. Currently, otime is never 
 even
 initialized, having undefined values. If it ever gets possible to
 access otime, we
 would at least have some inodes with valid otime fields.

I'll second that, even if by now the fields get correctly initialized.
Why should we zero the fields instead of setting them to the correct
values?

-Arne

--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Btrfs: Add code to support file creation time.

2012-07-09 Thread Li Zefan
On 2012/7/5 9:52, Alexander Block wrote:

 On Thu, Jul 5, 2012 at 3:07 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 19:04, Alexander Block wrote:

 On Wed, Jul 4, 2012 at 9:56 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.



 Well, how do users use this file creation time? There's no syscall and 
 there's
 no ioctl that exports this information. That xstat syscall hasn't been 
 accepted,
 so you can revise and repost the patch when you see it happens.
 In my opinion we should still include this patch. Currently, otime is never 
 even
 initialized, having undefined values. If it ever gets possible to
 access otime, we
 would at least have some inodes with valid otime fields.


 otime (on disk) is initialized to 0, not some undefined value. But yeah, 
 your point makes
 some sense, that with this patch we can access valid otime in an old 
 filesystem once we
 update to a new kernel which has otime support.
 This is true for the inode items found in the root tree. But the inode
 items found in the filesystem trees are not initialized at all. I did
 a fast check by adding printing of the otime field in
 btrfs-debug-tree...and every inode's otime looks random.
 btrfs_new_inode uses btrfs_insert_empty_items which does not zero the
 new item, then fill_inode_item is used to initialize the fields and
 there otime is missing.
 


That's bad..
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Btrfs: Add code to support file creation time.

2012-07-04 Thread Li Zefan
On 2012/7/4 19:04, Alexander Block wrote:

 On Wed, Jul 4, 2012 at 9:56 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.



 Well, how do users use this file creation time? There's no syscall and 
 there's
 no ioctl that exports this information. That xstat syscall hasn't been 
 accepted,
 so you can revise and repost the patch when you see it happens.
 In my opinion we should still include this patch. Currently, otime is never 
 even
 initialized, having undefined values. If it ever gets possible to
 access otime, we
 would at least have some inodes with valid otime fields.


otime (on disk) is initialized to 0, not some undefined value. But yeah, your 
point makes
some sense, that with this patch we can access valid otime in an old filesystem 
once we
update to a new kernel which has otime support.
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Btrfs: Add code to support file creation time.

2012-07-04 Thread Alexander Block
On Thu, Jul 5, 2012 at 3:07 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 19:04, Alexander Block wrote:

 On Wed, Jul 4, 2012 at 9:56 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.



 Well, how do users use this file creation time? There's no syscall and 
 there's
 no ioctl that exports this information. That xstat syscall hasn't been 
 accepted,
 so you can revise and repost the patch when you see it happens.
 In my opinion we should still include this patch. Currently, otime is never 
 even
 initialized, having undefined values. If it ever gets possible to
 access otime, we
 would at least have some inodes with valid otime fields.


 otime (on disk) is initialized to 0, not some undefined value. But yeah, your 
 point makes
 some sense, that with this patch we can access valid otime in an old 
 filesystem once we
 update to a new kernel which has otime support.
This is true for the inode items found in the root tree. But the inode
items found in the filesystem trees are not initialized at all. I did
a fast check by adding printing of the otime field in
btrfs-debug-tree...and every inode's otime looks random.
btrfs_new_inode uses btrfs_insert_empty_items which does not zero the
new item, then fill_inode_item is used to initialize the fields and
there otime is missing.
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Btrfs: Add code to support file creation time.

2012-07-04 Thread chandan r
This patch adds a new member to the 'struct btrfs_inode' structure to hold
the file creation time.

Signed-off-by: chandan chandanrm...@gmail.com
---
 fs/btrfs/btrfs_inode.h   |  3 +++
 fs/btrfs/ctree.h |  8 
 fs/btrfs/delayed-inode.c | 10 +-
 fs/btrfs/inode.c | 25 ++---
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 12394a9..b761456 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -162,6 +162,9 @@ struct btrfs_inode {
 
struct btrfs_delayed_node *delayed_node;
 
+   /* File creation time. */
+   struct timespec i_otime;
+
struct inode vfs_inode;
 };
 
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index fa5c45b..4ce172f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1816,6 +1816,14 @@ btrfs_inode_ctime(struct btrfs_inode_item *inode_item)
return (struct btrfs_timespec *)ptr;
 }
 
+static inline struct btrfs_timespec *
+btrfs_inode_otime(struct btrfs_inode_item *inode_item)
+{
+   unsigned long ptr = (unsigned long)inode_item;
+   ptr += offsetof(struct btrfs_inode_item, otime);
+   return (struct btrfs_timespec *)ptr;
+}
+
 BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64);
 BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
 
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 21d91a8..63726967 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1742,6 +1742,11 @@ static void fill_stack_inode_item(struct 
btrfs_trans_handle *trans,
 inode-i_ctime.tv_sec);
btrfs_set_stack_timespec_nsec(btrfs_inode_ctime(inode_item),
  inode-i_ctime.tv_nsec);
+
+   btrfs_set_stack_timespec_sec(btrfs_inode_otime(inode_item),
+   BTRFS_I(inode)-i_otime.tv_sec);
+   btrfs_set_stack_timespec_nsec(btrfs_inode_otime(inode_item),
+   BTRFS_I(inode)-i_otime.tv_nsec);
 }
 
 int btrfs_fill_inode(struct inode *inode, u32 *rdev)
@@ -1787,6 +1792,10 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
inode-i_ctime.tv_sec = btrfs_stack_timespec_sec(tspec);
inode-i_ctime.tv_nsec = btrfs_stack_timespec_nsec(tspec);
 
+   tspec = btrfs_inode_otime(inode_item);
+   BTRFS_I(inode)-i_otime.tv_sec = btrfs_stack_timespec_sec(tspec);
+   BTRFS_I(inode)-i_otime.tv_nsec = btrfs_stack_timespec_nsec(tspec);
+
inode-i_generation = BTRFS_I(inode)-generation;
BTRFS_I(inode)-index_cnt = (u64)-1;
 
@@ -1912,4 +1921,3 @@ void btrfs_destroy_delayed_inodes(struct btrfs_root *root)
btrfs_release_delayed_node(prev_node);
}
 }
-
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0d507e6..145a2ed 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2581,6 +2581,10 @@ static void btrfs_read_locked_inode(struct inode *inode)
inode-i_ctime.tv_sec = btrfs_timespec_sec(leaf, tspec);
inode-i_ctime.tv_nsec = btrfs_timespec_nsec(leaf, tspec);
 
+   tspec = btrfs_inode_otime(inode_item);
+   BTRFS_I(inode)-i_otime.tv_sec = btrfs_timespec_sec(leaf, tspec);
+   BTRFS_I(inode)-i_otime.tv_nsec = btrfs_timespec_nsec(leaf, tspec);
+
inode_set_bytes(inode, btrfs_inode_nbytes(leaf, inode_item));
BTRFS_I(inode)-generation = btrfs_inode_generation(leaf, inode_item);
inode-i_version = btrfs_inode_sequence(leaf, inode_item);
@@ -2665,6 +2669,11 @@ static void fill_inode_item(struct btrfs_trans_handle 
*trans,
btrfs_set_timespec_nsec(leaf, btrfs_inode_ctime(item),
inode-i_ctime.tv_nsec);
 
+   btrfs_set_timespec_sec(leaf, btrfs_inode_otime(item),
+   BTRFS_I(inode)-i_otime.tv_sec);
+   btrfs_set_timespec_nsec(leaf, btrfs_inode_otime(item),
+   BTRFS_I(inode)-i_otime.tv_nsec);
+
btrfs_set_inode_nbytes(leaf, item, inode_get_bytes(inode));
btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)-generation);
btrfs_set_inode_sequence(leaf, item, inode-i_version);
@@ -2846,7 +2855,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
}
return ret;
 }
-   
+
 
 /* helper to check if there is any shared block in the path */
 static int check_path_shared(struct btrfs_root *root,
@@ -4151,7 +4160,11 @@ static struct inode *new_simple_dir(struct super_block 
*s,
inode-i_op = btrfs_dir_ro_inode_operations;
inode-i_fop = simple_dir_operations;
inode-i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
-   inode-i_mtime = inode-i_atime = inode-i_ctime = CURRENT_TIME;
+   BTRFS_I(inode)-i_otime
+   = inode-i_mtime
+   = inode-i_atime
+   = inode-i_ctime
+   = CURRENT_TIME;
 
return inode;
 }
@@ -4687,7 +4700,11 @@ static struct 

Re: [PATCH] Btrfs: Add code to support file creation time.

2012-07-04 Thread Li Zefan
On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.
 


Well, how do users use this file creation time? There's no syscall and there's
no ioctl that exports this information. That xstat syscall hasn't been accepted,
so you can revise and repost the patch when you see it happens.
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Btrfs: Add code to support file creation time.

2012-07-04 Thread Alexander Block
On Wed, Jul 4, 2012 at 9:56 AM, Li Zefan lize...@huawei.com wrote:
 On 2012/7/4 15:18, chandan r wrote:

 This patch adds a new member to the 'struct btrfs_inode' structure to hold
 the file creation time.



 Well, how do users use this file creation time? There's no syscall and there's
 no ioctl that exports this information. That xstat syscall hasn't been 
 accepted,
 so you can revise and repost the patch when you see it happens.
In my opinion we should still include this patch. Currently, otime is never even
initialized, having undefined values. If it ever gets possible to
access otime, we
would at least have some inodes with valid otime fields.
 --
 To unsubscribe from this list: send the line unsubscribe linux-btrfs in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html