ceph: attempt to do async create when possible
Hello Jeff Layton,
The patch 9a8d03ca2e2c: "ceph: attempt to do async create when possible" from Nov 27, 2019, leads to the following static checker warning:
fs/ceph/file.c:540 ceph_async_create_cb() error: uninitialized symbol 'base'.
fs/ceph/file.c
526 mapping_set_error(req->r_parent->i_mapping, result);
527
528 if (result) {
529 struct dentry *dentry = req->r_dentry;
530 int pathlen;
531 u64 base;
^^^^^^^^
532 char *path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
533 &base, 0);
^^^^^
534
535 ceph_dir_clear_complete(req->r_parent);
536 if (!d_unhashed(dentry))
537 d_drop(dentry);
538
539 /* FIXME: start returning I/O errors on all accesses? */
540 pr_warn("ceph: async create failure path=(%llx)%s result=%d!\n",
541 base, IS_ERR(path) ? "<<bad>>" : path, result);
^^^^Potentialy uninitialized on error.
542 ceph_mdsc_free_path(path, pathlen);
543 }
544
545 if (req->r_target_inode) {regards,
dan carpenter
Quoted 29 lines · Dan Carpenter
Hello Jeff Layton,
The patch
9a8d03ca2e2c: "ceph: attempt to do async create when possible" from Nov 27, 2019, leads to the following static checker warning:fs/ceph/file.c:540 ceph_async_create_cb() error: uninitialized symbol 'base'.
fs/ceph/file.c526 mapping_set_error(req->r_parent->i_mapping, result); 527 528 if (result) { 529 struct dentry *dentry = req->r_dentry; 530 int pathlen; 531 u64 base; ^^^^^^^^ 532 char *path = ceph_mdsc_build_path(req->r_dentry, &pathlen, 533 &base, 0); ^^^^^ 534 535 ceph_dir_clear_complete(req->r_parent); 536 if (!d_unhashed(dentry)) 537 d_drop(dentry); 538 539 /* FIXME: start returning I/O errors on all accesses? */ 540 pr_warn("ceph: async create failure path=(%llx)%s result=%d!\n", 541 base, IS_ERR(path) ? "<<bad>>" : path, result); ^^^^
Quoted 3 lines
Potentialy uninitialized on error.
542 ceph_mdsc_free_path(path, pathlen);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Also this is quite problematic. "pathlen" can be uninitialized, but even worse the ceph_mdsc_free_path() assumes "path" is NULL on error instead of an error pointer.
Quoted 3 lines
543 }
544
545 if (req->r_target_inode) {regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Hello Jeff Layton,
The patch
9a8d03ca2e2c: "ceph: attempt to do async create when possible" from Nov 27, 2019, leads to the following static checker warning:fs/ceph/file.c:540 ceph_async_create_cb() error: uninitialized symbol 'base'.
Sorry, see the unlink function as well.
fs/ceph/dir.c:1072 ceph_async_unlink_cb()
error: uninitialized symbol 'pathlen'.
regards,
dan carpenter
Quoted 10 lines · Dan Carpenter
Quoted 8 lines · Dan Carpenter
Hello Jeff Layton,
The patch
9a8d03ca2e2c: "ceph: attempt to do async create when possible" from Nov 27, 2019, leads to the following static checker warning:fs/ceph/file.c:540 ceph_async_create_cb() error: uninitialized symbol 'base'.
Quoted 8 lines
Sorry, see the unlink function as well.
fs/ceph/dir.c:1072ceph_async_unlink_cb()
error: uninitialized symbol 'pathlen'.regards,
dan carpenter
Many thanks, Dan!
I think the right thing to do is probably to just make ceph_mdsc_free_path not do anything when it gets a IS_ERR value. At the same time, this is also an error path, so we might as well initialize the values we're passing into ceph_mdsc_build_path to make sure the warnings look sane. See the attached two patches.
Since this code is not upstream yet, I'll probably just move the first one to be before the async create/delete patches go in, and squash the second one into the respective patches that add that functionality so we don't have any regressions.
Sound ok?
Signature · 1 line
Jeff Layton <[email protected]>
From 06e892961013cfbd6f48239794669ba34b812052 Mon Sep 17 00:00:00 2001
From: Jeff Layton <[email protected]>
Date: Wed, 8 Apr 2020 08:40:33 -0400
Subject: [PATCH 1/2] ceph: have ceph_mdsc_free_path ignore ERR_PTR values
This makes the error handling simpler in some callers.
--- fs/ceph/mds_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/mds_client.h +1 -1
@@ -531,7 +531,7 @@ extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);static inline void ceph_mdsc_free_path (char *path,int len) { -if (path) +if (path && !IS_ERR (path))__putname (path - (PATH_MAX -1 - len)); }
Signature · 1 line
2.25.2
From 066f69dfd78a20ad9aa5f7e387da6886c8410ce2 Mon Sep 17 00:00:00 2001
From: Jeff Layton <[email protected]>
Date: Wed, 8 Apr 2020 08:41:38 -0400
Subject: [PATCH 2/2] SQUASH: initialize path and base values in async dirops
cb's
--- fs/ceph/dir.c | 4 ++-- fs/ceph/file.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/ceph/dir.c +2 -2
@@ -1057,8 +1057,8 @@ static void ceph_async_unlink_cb(struct ceph_mds_client *mdsc,/* If op failed, mark everyone involved for errors */ if (result) { -int pathlen; -u64 base; +int pathlen =0 ; +u64 base =0 ;char *path =ceph_mdsc_build_path (req->r_dentry, &pathlen, &base,0 );
fs/ceph/file.c +2 -2
@@ -529,8 +529,8 @@ static void ceph_async_create_cb(struct ceph_mds_client *mdsc,if (result) {struct dentry *dentry = req->r_dentry; -int pathlen; -u64 base; +int pathlen =0 ; +u64 base =0 ;char *path =ceph_mdsc_build_path (req->r_dentry, &pathlen, &base,0 );
Signature · 1 line
2.25.2
Quoted 2 lines · Jeff Layton
Sound ok?
Sounds good.
fs/ceph/mds_client.h extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc); · line 534
Quoted 13 lines
fs/ceph/mds_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/ceph/mds_client.h +1
-1@@ -531,7 +531,7 @@ extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);static inline void ceph_mdsc_free_path (char *path,int len) { -if (path) +if (path && !IS_ERR (path))
if (!IS_ERR_OR_NULL(path)
Quoted 6 lines
fs/ceph/mds_client.h +0
-0__putname (path - (PATH_MAX -1 - len)); }Signature · 1 line
2.25.2
regards,
dan carpenter