summaryrefslogtreecommitdiffstats
path: root/xlators/performance/write-behind
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-12-12 16:45:09 -0500
committerAmar Tumballi <amarts@redhat.com>2018-12-14 04:33:15 +0000
commitbfe2b5e1530efd364af7a175c8a1c89bc4cab0bb (patch)
tree2030f52c92661f8d285c9905481787dced506a91 /xlators/performance/write-behind
parent8293d21280fd6ddfc9bb54068cf87794fc6be207 (diff)
clang: Fix various missing checks for empty list
When using list_for_each_entry(_safe) functions, care needs to be taken that the list passed in are not empty, as these functions are not empty list safe. clag scan reported various points where this this pattern could be caught, and this patch fixes the same. Additionally the following changes are present in this patch, - Added an explicit op_ret setting in error case in the macro MAKE_INODE_HANDLE to address another clang issue reported - Minor refactoring of some functions in quota code, to address possible allocation failures in certain functions (which in turn cause possible empty lists to be passed around) Change-Id: I1e761a8d218708f714effb56fa643df2a3ea2cc7 Updates: bz#1622665 Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'xlators/performance/write-behind')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index f90abad38da..98b2f4639d3 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1744,15 +1744,9 @@ wb_do_winds(wb_inode_t *wb_inode, list_head_t *tasks)
void
wb_process_queue(wb_inode_t *wb_inode)
{
- list_head_t tasks = {
- 0,
- };
- list_head_t lies = {
- 0,
- };
- list_head_t liabilities = {
- 0,
- };
+ list_head_t tasks;
+ list_head_t lies;
+ list_head_t liabilities;
int wind_failure = 0;
INIT_LIST_HEAD(&tasks);
@@ -1773,15 +1767,18 @@ wb_process_queue(wb_inode_t *wb_inode)
}
UNLOCK(&wb_inode->lock);
- wb_do_unwinds(wb_inode, &lies);
+ if (!list_empty(&lies))
+ wb_do_unwinds(wb_inode, &lies);
- wb_do_winds(wb_inode, &tasks);
+ if (!list_empty(&tasks))
+ wb_do_winds(wb_inode, &tasks);
/* If there is an error in wb_fulfill before winding write
* requests, we would miss invocation of wb_process_queue
* from wb_fulfill_cbk. So, retry processing again.
*/
- wind_failure = wb_fulfill(wb_inode, &liabilities);
+ if (!list_empty(&liabilities))
+ wind_failure = wb_fulfill(wb_inode, &liabilities);
} while (wind_failure);
return;