From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
To: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/3] cifs: use CreationTime like an i_generation field
Date: Mon, 28 Jun 2010 18:56:09 +0530 [thread overview]
Message-ID: <4C28A2F1.1040309@suse.de> (raw)
In-Reply-To: <1277723413-23769-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 06/28/2010 04:40 PM, Jeff Layton wrote:
> Reduce false inode collisions by using the CreationTime like an
> i_generation field. This way, even if the server ends up reusing
> a uniqueid after a delete/create cycle, we can avoid matching
> the inode incorrectly.
>
> Signed-off-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> fs/cifs/cifsfs.c | 2 ++
> fs/cifs/cifsglob.h | 2 ++
> fs/cifs/inode.c | 6 ++++++
> fs/cifs/readdir.c | 1 +
> 4 files changed, 11 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index 484e52b..e409216 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -314,6 +314,8 @@ cifs_alloc_inode(struct super_block *sb)
> cifs_inode->invalid_mapping = false;
> cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
> cifs_inode->server_eof = 0;
> + cifs_inode->uniqueid = 0;
> + cifs_inode->createtime = 0;
>
> /* Can not set i_flags here - they get immediately overwritten
> to zero by the VFS */
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index e15d7a5..a0fd2c2 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -382,6 +382,7 @@ struct cifsInodeInfo {
> bool invalid_mapping:1; /* pagecache is invalid */
> u64 server_eof; /* current file size on server */
> u64 uniqueid; /* server inode number */
> + u64 createtime; /* creation time on server */
> struct inode vfs_inode;
> };
>
> @@ -499,6 +500,7 @@ struct cifs_fattr {
> u64 cf_uniqueid;
> u64 cf_eof;
> u64 cf_bytes;
> + u64 cf_createtime;
> uid_t cf_uid;
> gid_t cf_gid;
> umode_t cf_mode;
> diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
> index f64b95f..35e2466 100644
> --- a/fs/cifs/inode.c
> +++ b/fs/cifs/inode.c
> @@ -487,6 +487,7 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
>
> fattr->cf_eof = le64_to_cpu(info->EndOfFile);
> fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
> + fattr->cf_createtime = le64_to_cpu(info->CreationTime);
>
> if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
> fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
> @@ -727,6 +728,10 @@ cifs_find_inode(struct inode *inode, void *opaque)
> if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
> return 0;
>
> + /* use createtime like an i_generation field */
> + if (CIFS_I(inode)->createtime != fattr->cf_createtime)
> + return 0;
> +
> /* don't match inode of different type */
> if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
> return 0;
> @@ -750,6 +755,7 @@ cifs_init_inode(struct inode *inode, void *opaque)
> struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
>
> CIFS_I(inode)->uniqueid = fattr->cf_uniqueid;
> + CIFS_I(inode)->createtime = fattr->cf_createtime;
> return 0;
> }
>
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index daf1753..8bd18be 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -160,6 +160,7 @@ cifs_dir_info_to_fattr(struct cifs_fattr *fattr, FILE_DIRECTORY_INFO *info,
> fattr->cf_cifsattrs = le32_to_cpu(info->ExtFileAttributes);
> fattr->cf_eof = le64_to_cpu(info->EndOfFile);
> fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
> + fattr->cf_createtime = le64_to_cpu(info->CreationTime);
cifs_std_info_to_fattr() needs this too?
> fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
> fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
> fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
--
Suresh Jayaraman
next prev parent reply other threads:[~2010-06-28 13:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-28 11:10 [PATCH 0/3] cifs: tighten up cifs_iget matching criteria Jeff Layton
2010-06-28 11:10 ` [PATCH 1/3] cifs: don't allow cifs_iget to match inodes of the wrong type Jeff Layton
[not found] ` <1277723413-23769-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-06-28 11:10 ` [PATCH 2/3] cifs: use CreationTime like an i_generation field Jeff Layton
[not found] ` <1277723413-23769-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-06-28 13:26 ` Suresh Jayaraman [this message]
2010-06-28 13:47 ` Jeff Layton
2010-11-22 19:55 ` Jeff Layton
[not found] ` <AANLkTimtg0vFVQ5HGo+nq7rE=Z4Sob=z7LuVCMFgWdnv@mail.gmail.com>
[not found] ` <AANLkTimtg0vFVQ5HGo+nq7rE=Z4Sob=z7LuVCMFgWdnv-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-22 20:31 ` Jeff Layton
[not found] ` <20101122153125.68ee4ee6-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2010-11-22 20:59 ` Jeremy Allison
2010-12-07 1:55 ` Jeff Layton
2010-06-28 11:10 ` [PATCH 3/3] cifs: reduce false positives with inode aliasing serverino autodisable Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C28A2F1.1040309@suse.de \
--to=sjayaraman-l3a5bk7wagm@public.gmane.org \
--cc=jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.