cifs: vary timeout on writes past EOF based on offset (try #5)
This is the fourth version of this patch: The first three generated a compiler warning asking for explicit curly braces. The first two didn't handle update the size correctly when writes that didn't start at the eof were done. The first patch also didn't update the size correctly when it explicitly set via truncate(). This patch adds code to track the client's current understanding of the size of the file on the server separate from the i_size, and then to use this info to semi-intelligently set the timeout for writes past the EOF. This helps prevent timeouts when trying to write large, sparse files on windows servers. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
committed by
Steve French
parent
d036f50fc2
commit
fbec9ab952
@@ -143,6 +143,7 @@ static void cifs_unix_info_to_inode(struct inode *inode,
|
||||
|
||||
inode->i_nlink = le64_to_cpu(info->Nlinks);
|
||||
|
||||
cifsInfo->server_eof = end_of_file;
|
||||
spin_lock(&inode->i_lock);
|
||||
if (is_size_safe_to_change(cifsInfo, end_of_file)) {
|
||||
/*
|
||||
@@ -606,12 +607,12 @@ int cifs_get_inode_info(struct inode **pinode,
|
||||
inode->i_mode |= S_IFREG;
|
||||
}
|
||||
|
||||
cifsInfo->server_eof = le64_to_cpu(pfindData->EndOfFile);
|
||||
spin_lock(&inode->i_lock);
|
||||
if (is_size_safe_to_change(cifsInfo,
|
||||
le64_to_cpu(pfindData->EndOfFile))) {
|
||||
if (is_size_safe_to_change(cifsInfo, cifsInfo->server_eof)) {
|
||||
/* can not safely shrink the file size here if the
|
||||
client is writing to it due to potential races */
|
||||
i_size_write(inode, le64_to_cpu(pfindData->EndOfFile));
|
||||
i_size_write(inode, cifsInfo->server_eof);
|
||||
|
||||
/* 512 bytes (2**9) is the fake blocksize that must be
|
||||
used for this calculation */
|
||||
@@ -1755,6 +1756,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
cifsInode->server_eof = attrs->ia_size;
|
||||
rc = cifs_vmtruncate(inode, attrs->ia_size);
|
||||
cifs_truncate_page(inode->i_mapping, inode->i_size);
|
||||
}
|
||||
|
Reference in New Issue
Block a user