Commit 20054bd6 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: use CreationTime like an i_generation field

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: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent d44a9fe2
...@@ -329,6 +329,8 @@ cifs_alloc_inode(struct super_block *sb) ...@@ -329,6 +329,8 @@ cifs_alloc_inode(struct super_block *sb)
cifs_inode->invalid_mapping = false; cifs_inode->invalid_mapping = false;
cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
cifs_inode->server_eof = 0; cifs_inode->server_eof = 0;
cifs_inode->uniqueid = 0;
cifs_inode->createtime = 0;
/* Can not set i_flags here - they get immediately overwritten /* Can not set i_flags here - they get immediately overwritten
to zero by the VFS */ to zero by the VFS */
......
...@@ -453,6 +453,7 @@ struct cifsInodeInfo { ...@@ -453,6 +453,7 @@ struct cifsInodeInfo {
bool invalid_mapping:1; /* pagecache is invalid */ bool invalid_mapping:1; /* pagecache is invalid */
u64 server_eof; /* current file size on server */ u64 server_eof; /* current file size on server */
u64 uniqueid; /* server inode number */ u64 uniqueid; /* server inode number */
u64 createtime; /* creation time on server */
#ifdef CONFIG_CIFS_FSCACHE #ifdef CONFIG_CIFS_FSCACHE
struct fscache_cookie *fscache; struct fscache_cookie *fscache;
#endif #endif
...@@ -573,6 +574,7 @@ struct cifs_fattr { ...@@ -573,6 +574,7 @@ struct cifs_fattr {
u64 cf_uniqueid; u64 cf_uniqueid;
u64 cf_eof; u64 cf_eof;
u64 cf_bytes; u64 cf_bytes;
u64 cf_createtime;
uid_t cf_uid; uid_t cf_uid;
gid_t cf_gid; gid_t cf_gid;
umode_t cf_mode; umode_t cf_mode;
......
...@@ -518,6 +518,7 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, ...@@ -518,6 +518,7 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
fattr->cf_eof = le64_to_cpu(info->EndOfFile); fattr->cf_eof = le64_to_cpu(info->EndOfFile);
fattr->cf_bytes = le64_to_cpu(info->AllocationSize); fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
fattr->cf_createtime = le64_to_cpu(info->CreationTime);
if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { if (fattr->cf_cifsattrs & ATTR_DIRECTORY) {
fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode; fattr->cf_mode = S_IFDIR | cifs_sb->mnt_dir_mode;
...@@ -779,6 +780,10 @@ cifs_find_inode(struct inode *inode, void *opaque) ...@@ -779,6 +780,10 @@ cifs_find_inode(struct inode *inode, void *opaque)
if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid) if (CIFS_I(inode)->uniqueid != fattr->cf_uniqueid)
return 0; 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 */ /* don't match inode of different type */
if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT)) if ((inode->i_mode & S_IFMT) != (fattr->cf_mode & S_IFMT))
return 0; return 0;
...@@ -796,6 +801,7 @@ cifs_init_inode(struct inode *inode, void *opaque) ...@@ -796,6 +801,7 @@ cifs_init_inode(struct inode *inode, void *opaque)
struct cifs_fattr *fattr = (struct cifs_fattr *) opaque; struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
CIFS_I(inode)->uniqueid = fattr->cf_uniqueid; CIFS_I(inode)->uniqueid = fattr->cf_uniqueid;
CIFS_I(inode)->createtime = fattr->cf_createtime;
return 0; return 0;
} }
......
...@@ -160,6 +160,7 @@ cifs_dir_info_to_fattr(struct cifs_fattr *fattr, FILE_DIRECTORY_INFO *info, ...@@ -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_cifsattrs = le32_to_cpu(info->ExtFileAttributes);
fattr->cf_eof = le64_to_cpu(info->EndOfFile); fattr->cf_eof = le64_to_cpu(info->EndOfFile);
fattr->cf_bytes = le64_to_cpu(info->AllocationSize); fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
fattr->cf_createtime = le64_to_cpu(info->CreationTime);
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment