提交 08c0cf5a 编写于 作者: S Steve French 提交者: Xie XiuQi

cifs: track writepages in vfs operation counters

mainline inclusion
from mainline-v4.20-rc1
commit 0cb012d1a0a9ead759112da141698a2078fbf2ce
category: bugfix
bugzilla: 12058
CVE: NA

-------------------------------------------------

writepages and readpages operations did not call get/free_xid
so the statistics for file copy could get confusing with "vfs operations"
not increasing.  Add get_xid and free_xid to cifs readpages and
writepages functions.
Signed-off-by: NSteve French <stfrench@microsoft.com>
Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: NZhangXiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: Nzhengbin <zhengbin13@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 73413fb8
...@@ -2118,6 +2118,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -2118,6 +2118,7 @@ static int cifs_writepages(struct address_space *mapping,
pgoff_t end, index; pgoff_t end, index;
struct cifs_writedata *wdata; struct cifs_writedata *wdata;
int rc = 0; int rc = 0;
unsigned int xid;
/* /*
* If wsize is smaller than the page cache size, default to writing * If wsize is smaller than the page cache size, default to writing
...@@ -2126,6 +2127,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -2126,6 +2127,7 @@ static int cifs_writepages(struct address_space *mapping,
if (cifs_sb->wsize < PAGE_SIZE) if (cifs_sb->wsize < PAGE_SIZE)
return generic_writepages(mapping, wbc); return generic_writepages(mapping, wbc);
xid = get_xid();
if (wbc->range_cyclic) { if (wbc->range_cyclic) {
index = mapping->writeback_index; /* Start from prev offset */ index = mapping->writeback_index; /* Start from prev offset */
end = -1; end = -1;
...@@ -2219,6 +2221,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -2219,6 +2221,7 @@ static int cifs_writepages(struct address_space *mapping,
if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
mapping->writeback_index = index; mapping->writeback_index = index;
free_xid(xid);
return rc; return rc;
} }
...@@ -3770,7 +3773,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -3770,7 +3773,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
pid_t pid; pid_t pid;
unsigned int xid;
xid = get_xid();
/* /*
* Reads as many pages as possible from fscache. Returns -ENOBUFS * Reads as many pages as possible from fscache. Returns -ENOBUFS
* immediately if the cookie is negative * immediately if the cookie is negative
...@@ -3780,8 +3785,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -3780,8 +3785,10 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
*/ */
rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list, rc = cifs_readpages_from_fscache(mapping->host, mapping, page_list,
&num_pages); &num_pages);
if (rc == 0) if (rc == 0) {
free_xid(xid);
return rc; return rc;
}
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
pid = open_file->pid; pid = open_file->pid;
...@@ -3825,6 +3832,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -3825,6 +3832,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
*/ */
if (unlikely(rsize < PAGE_SIZE)) { if (unlikely(rsize < PAGE_SIZE)) {
add_credits_and_wake_if(server, credits, 0); add_credits_and_wake_if(server, credits, 0);
free_xid(xid);
return 0; return 0;
} }
...@@ -3889,6 +3897,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -3889,6 +3897,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
* allocator. * allocator.
*/ */
cifs_fscache_readpages_cancel(mapping->host, page_list); cifs_fscache_readpages_cancel(mapping->host, page_list);
free_xid(xid);
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册