Commit b54f71cf authored by Pavel Shilovsky's avatar Pavel Shilovsky

Update 3.4 sources from stable (v3.4.91)

parent 6acef63e
...@@ -2191,7 +2191,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, ...@@ -2191,7 +2191,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *poffset) unsigned long nr_segs, loff_t *poffset)
{ {
unsigned long nr_pages, i; unsigned long nr_pages, i;
size_t copied, len, cur_len; size_t bytes, copied, len, cur_len;
ssize_t total_written = 0; ssize_t total_written = 0;
loff_t offset; loff_t offset;
struct iov_iter it; struct iov_iter it;
...@@ -2242,14 +2242,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov, ...@@ -2242,14 +2242,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
save_len = cur_len; save_len = cur_len;
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
copied = min_t(const size_t, cur_len, PAGE_SIZE); bytes = min_t(const size_t, cur_len, PAGE_SIZE);
copied = iov_iter_copy_from_user(wdata->pages[i], &it, copied = iov_iter_copy_from_user(wdata->pages[i], &it,
0, copied); 0, bytes);
cur_len -= copied; cur_len -= copied;
iov_iter_advance(&it, copied); iov_iter_advance(&it, copied);
/*
* If we didn't copy as much as we expected, then that
* may mean we trod into an unmapped area. Stop copying
* at that point. On the next pass through the big
* loop, we'll likely end up getting a zero-length
* write and bailing out of it.
*/
if (copied < bytes)
break;
} }
cur_len = save_len - cur_len; cur_len = save_len - cur_len;
/*
* If we have no data to send, then that probably means that
* the copy above failed altogether. That's most likely because
* the address in the iovec was bogus. Set the rc to -EFAULT,
* free anything we allocated and bail out.
*/
if (!cur_len) {
for (i = 0; i < nr_pages; i++)
put_page(wdata->pages[i]);
kfree(wdata);
rc = -EFAULT;
break;
}
/*
* i + 1 now represents the number of pages we actually used in
* the copy phase above. Bring nr_pages down to that, and free
* any pages that we didn't use.
*/
for ( ; nr_pages > i + 1; nr_pages--)
put_page(wdata->pages[nr_pages - 1]);
wdata->sync_mode = WB_SYNC_ALL; wdata->sync_mode = WB_SYNC_ALL;
wdata->nr_pages = nr_pages; wdata->nr_pages = nr_pages;
wdata->offset = (__u64)offset; wdata->offset = (__u64)offset;
......
...@@ -96,6 +96,14 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, ...@@ -96,6 +96,14 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
dput(dentry); dput(dentry);
} }
/*
* If we know that the inode will need to be revalidated immediately,
* then don't create a new dentry for it. We'll end up doing an on
* the wire call either way and this spares us an invalidation.
*/
if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
return NULL;
dentry = d_alloc(parent, name); dentry = d_alloc(parent, name);
if (dentry == NULL) if (dentry == NULL)
return NULL; return NULL;
......
...@@ -511,6 +511,13 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf, ...@@ -511,6 +511,13 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf,
mutex_unlock(&server->srv_mutex); mutex_unlock(&server->srv_mutex);
return rc; return rc;
} }
/*
* The response to this call was already factored into the sequence
* number when the call went out, so we must adjust it back downward
* after signing here.
*/
--server->sequence_number;
rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
mutex_unlock(&server->srv_mutex); mutex_unlock(&server->srv_mutex);
......
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