Re: [RFC] [PATCH 2/2] Btrfs: move over to use ->update_time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Mimi and I working on IMA/EVM (security/integrity) and it uses
i_version for checking if file content has been changed.
extX file systems support i_version updates with mounting file system
with "iversion" option or via kernel command line parameter
"i_version"

It seems iversion option is not recognized when mounting btrfs.
I see this patchset deals with i_version update as well..
Can you please give an advice how to use i_version with btrfs?

Thanks,
Dmitry

On Mon, Mar 26, 2012 at 5:10 PM, Josef Bacik <josef@xxxxxxxxxx> wrote:
> Btrfs had been doing it's own file_update_time so we could catch ENOSPC
> properly, so just update our btrfs_update_time to work with the new stuff and
> then we'll be fancy later.  Thanks,
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxx>
> ---
>  fs/btrfs/ctree.h |    1 -
>  fs/btrfs/file.c  |    2 +-
>  fs/btrfs/inode.c |   53 ++++++++++++++---------------------------------------
>  3 files changed, 15 insertions(+), 41 deletions(-)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 9d6f59c..9e4a06e 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -2887,7 +2887,6 @@ int btrfs_readpage(struct file *file, struct page *page);
>  void btrfs_evict_inode(struct inode *inode);
>  int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc);
>  int btrfs_dirty_inode(struct inode *inode);
> -int btrfs_update_time(struct file *file);
>  struct inode *btrfs_alloc_inode(struct super_block *sb);
>  void btrfs_destroy_inode(struct inode *inode);
>  int btrfs_drop_inode(struct inode *inode);
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 859ba2d..50b8cea 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -1389,7 +1389,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
>                goto out;
>        }
>
> -       err = btrfs_update_time(file);
> +       err = file_update_time(file);
>        if (err) {
>                mutex_unlock(&inode->i_mutex);
>                goto out;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index c2c44d6..2c7359b 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4287,46 +4287,18 @@ int btrfs_dirty_inode(struct inode *inode)
>  * This is a copy of file_update_time.  We need this so we can return error on
>  * ENOSPC for updating the inode in the case of file write and mmap writes.
>  */
> -int btrfs_update_time(struct file *file)
> +static int btrfs_update_time(struct inode *inode, struct timespec *now,
> +                            int flags)
>  {
> -       struct inode *inode = file->f_path.dentry->d_inode;
> -       struct timespec now;
> -       int ret;
> -       enum { S_MTIME = 1, S_CTIME = 2, S_VERSION = 4 } sync_it = 0;
> -
> -       /* First try to exhaust all avenues to not sync */
> -       if (IS_NOCMTIME(inode))
> -               return 0;
> -
> -       now = current_fs_time(inode->i_sb);
> -       if (!timespec_equal(&inode->i_mtime, &now))
> -               sync_it = S_MTIME;
> -
> -       if (!timespec_equal(&inode->i_ctime, &now))
> -               sync_it |= S_CTIME;
> -
> -       if (IS_I_VERSION(inode))
> -               sync_it |= S_VERSION;
> -
> -       if (!sync_it)
> -               return 0;
> -
> -       /* Finally allowed to write? Takes lock. */
> -       if (mnt_want_write_file(file))
> -               return 0;
> -
> -       /* Only change inode inside the lock region */
> -       if (sync_it & S_VERSION)
> +       if (flags & S_VERSION)
>                inode_inc_iversion(inode);
> -       if (sync_it & S_CTIME)
> -               inode->i_ctime = now;
> -       if (sync_it & S_MTIME)
> -               inode->i_mtime = now;
> -       ret = btrfs_dirty_inode(inode);
> -       if (!ret)
> -               mark_inode_dirty_sync(inode);
> -       mnt_drop_write(file->f_path.mnt);
> -       return ret;
> +       if (flags & S_CTIME)
> +               inode->i_ctime = *now;
> +       if (flags & S_MTIME)
> +               inode->i_mtime = *now;
> +       if (flags & S_ATIME)
> +               inode->i_atime = *now;
> +       return btrfs_dirty_inode(inode);
>  }
>
>  /*
> @@ -6405,7 +6377,7 @@ int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
>
>        ret  = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE);
>        if (!ret)
> -               ret = btrfs_update_time(vma->vm_file);
> +               ret = file_update_time(vma->vm_file);
>        if (ret) {
>                if (ret == -ENOMEM)
>                        ret = VM_FAULT_OOM;
> @@ -7451,6 +7423,7 @@ static const struct inode_operations btrfs_file_inode_operations = {
>        .permission     = btrfs_permission,
>        .fiemap         = btrfs_fiemap,
>        .get_acl        = btrfs_get_acl,
> +       .update_time    = btrfs_update_time,
>  };
>  static const struct inode_operations btrfs_special_inode_operations = {
>        .getattr        = btrfs_getattr,
> @@ -7461,6 +7434,7 @@ static const struct inode_operations btrfs_special_inode_operations = {
>        .listxattr      = btrfs_listxattr,
>        .removexattr    = btrfs_removexattr,
>        .get_acl        = btrfs_get_acl,
> +       .update_time    = btrfs_update_time,
>  };
>  static const struct inode_operations btrfs_symlink_inode_operations = {
>        .readlink       = generic_readlink,
> @@ -7474,6 +7448,7 @@ static const struct inode_operations btrfs_symlink_inode_operations = {
>        .listxattr      = btrfs_listxattr,
>        .removexattr    = btrfs_removexattr,
>        .get_acl        = btrfs_get_acl,
> +       .update_time    = btrfs_update_time,
>  };
>
>  const struct dentry_operations btrfs_dentry_operations = {
> --
> 1.7.5.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux