Skip to contentSkip to conversation

ceph: fix dout logs for null pointers

PATCH In review [email protected] 3 participants 10 messages Feb 17, 2020 – Feb 18, 2020 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix dout logs for null pointers

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
 fs/ceph/dir.c        | 2 +-
 fs/ceph/mds_client.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
 	err = ceph_handle_snapdir(req, dentry, err);
 	dentry = ceph_finish_lookup(req, dentry, err);
 	ceph_mdsc_put_request(req);  /* will dput(dentry) */
-	dout("lookup result=%p\n", dentry);
+	dout("lookup result=%d\n", err);
 	return dentry;
 }
 
fs/ceph/mds_client.c +5 -1
index b6aa357f7c61..e34f159d262b 100644
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
 		ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
 				  CEPH_CAP_PIN);
 
-	dout("submit_request on %p for inode %p\n", req, dir);
+	if (dir)
+		dout("submit_request on %p for inode %p\n", req, dir);
+	else
+		dout("submit_request on %p\n", req);
+
 	mutex_lock(&mdsc->mutex);
 	__register_request(mdsc, req, dir);
 	__do_request(mdsc, req);
Signature · 1 line
2.21.0
#1 lore raw
Quoted 19 lines · On Mon, 2020-02-17 at 06:28 -0500, [email protected] wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
 fs/ceph/dir.c        | 2 +-
 fs/ceph/mds_client.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +0 -0
index ffeaff5bf211..245a262ec198 100644

fs/ceph/dir.c static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, · line 804

Quoted 8 lines
fs/ceph/dir.c +1 -1
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
 	err = ceph_handle_snapdir(req, dentry, err);
 	dentry = ceph_finish_lookup(req, dentry, err);
 	ceph_mdsc_put_request(req);  /* will dput(dentry) */
-	dout("lookup result=%p\n", dentry);
+	dout("lookup result=%d\n", err);
 	return dentry;
 }
 

The existing error handling in this function is really hard to follow (the way that "err" is passed to subsequent functions). It really took me a minute to figure out whether this change would make sense for all the cases. I think it does, but it might be nice to do a larger reorganization of this code if you're interested in improving it.

Quoted 7 lines
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
 		ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
 				  CEPH_CAP_PIN);

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2782

Quoted 10 lines
fs/ceph/mds_client.c +5 -1
 
-	dout("submit_request on %p for inode %p\n", req, dir);
+	if (dir)
+		dout("submit_request on %p for inode %p\n", req, dir);
+	else
+		dout("submit_request on %p\n", req);
+
 	mutex_lock(&mdsc->mutex);
 	__register_request(mdsc, req, dir);
 	__do_request(mdsc, req);

I'll merge into testing later today.

Signature · 1 line
Jeff Layton <[email protected]>
author
#2 lore raw
Quoted 25 lines · Jeff Layton
Quoted 24 lines · On Mon, 2020-02-17 at 06:28 -0500, [email protected] wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
  fs/ceph/dir.c        | 2 +-
  fs/ceph/mds_client.c | 6 +++++-
  2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
  	err = ceph_handle_snapdir(req, dentry, err);
  	dentry = ceph_finish_lookup(req, dentry, err);
  	ceph_mdsc_put_request(req);  /* will dput(dentry) */
-	dout("lookup result=%p\n", dentry);
+	dout("lookup result=%d\n", err);
Quoted 8 lines

fs/ceph/dir.c static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, · line 804

Quoted 3 lines
fs/ceph/dir.c +0 -0
  	return dentry;
  }
 

The existing error handling in this function is really hard to follow (the way that "err" is passed to subsequent functions). It really took me a minute to figure out whether this change would make sense for all the cases. I think it does, but it might be nice to do a larger reorganization of this code if you're interested in improving it.

yeah, sure I will do it later.

Thanks.

Quoted 19 lines
Quoted 7 lines
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
  		ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
  				  CEPH_CAP_PIN);

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2782

Quoted 10 lines
fs/ceph/mds_client.c +5 -1
 
-	dout("submit_request on %p for inode %p\n", req, dir);
+	if (dir)
+		dout("submit_request on %p for inode %p\n", req, dir);
+	else
+		dout("submit_request on %p\n", req);
+
  	mutex_lock(&mdsc->mutex);
  	__register_request(mdsc, req, dir);
  	__do_request(mdsc, req);

I'll merge into testing later today.

maintainer
#3 lore raw
In reply to [email protected]
Quoted 33 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
 fs/ceph/dir.c        | 2 +-
 fs/ceph/mds_client.c | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
        err = ceph_handle_snapdir(req, dentry, err);
        dentry = ceph_finish_lookup(req, dentry, err);
        ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
        return dentry;
 }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                  CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Thanks,

Ilya

author
#4 lore raw
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
  fs/ceph/dir.c        | 2 +-
  fs/ceph/mds_client.c | 6 +++++-
  2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
         err = ceph_handle_snapdir(req, dentry, err);
         dentry = ceph_finish_lookup(req, dentry, err);
         ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
         return dentry;
  }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                 ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                   CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

Thanks,

Quoted 4 lines

Thanks,

Ilya

maintainer
#5 lore raw
Quoted 57 lines · Xiubo Li
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
  fs/ceph/dir.c        | 2 +-
  fs/ceph/mds_client.c | 6 +++++-
  2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
         err = ceph_handle_snapdir(req, dentry, err);
         dentry = ceph_finish_lookup(req, dentry, err);
         ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
         return dentry;
  }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                 ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                   CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

Quoted 7 lines

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

I was reacting to ceph_mdsc_submit_request() hunk. Feel free to tweak ceph_lookup() or refactor it so that err is not threaded through three different functions as Jeff suggested.

Thanks,

Ilya

author
#6 lore raw
Quoted 60 lines · Ilya Dryomov
Quoted 59 lines · Xiubo Li
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
   fs/ceph/dir.c        | 2 +-
   fs/ceph/mds_client.c | 6 +++++-
   2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
          err = ceph_handle_snapdir(req, dentry, err);
          dentry = ceph_finish_lookup(req, dentry, err);
          ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
          return dentry;
   }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                  ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                    CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

Quoted 6 lines
Quoted 3 lines

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

I was reacting to ceph_mdsc_submit_request() hunk. Feel free to tweak ceph_lookup() or refactor it so that err is not threaded through three different functions as Jeff suggested.

Hi Ilya

Oh okay. You are right we can figure out what we need via many other dout logs.

I just saw some very confusing logs that the "dentry" in cpeh_lookup() and the "inode" in _submit_ are all 000000007a1ca695, so I addressed them both here.

Thanks,

BRs

Quoted 4 lines

Thanks,

Ilya

#7 lore raw
Quoted 68 lines · Xiubo Li
Quoted 60 lines · Ilya Dryomov
Quoted 59 lines · Xiubo Li
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
   fs/ceph/dir.c        | 2 +-
   fs/ceph/mds_client.c | 6 +++++-
   2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
          err = ceph_handle_snapdir(req, dentry, err);
          dentry = ceph_finish_lookup(req, dentry, err);
          ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
          return dentry;
   }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                  ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                    CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

Quoted 6 lines
Quoted 3 lines

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

I was reacting to ceph_mdsc_submit_request() hunk. Feel free to tweak ceph_lookup() or refactor it so that err is not threaded through three different functions as Jeff suggested.

Quoted 9 lines

Hi Ilya

Oh okay. You are right we can figure out what we need via many other dout logs.

I just saw some very confusing logs that the "dentry" in cpeh_lookup() and the "inode" in _submit_ are all 000000007a1ca695, so I addressed them both here.

Since Ilya objected to this patch, I'll drop it from testing for now. Please send a v2 that addresses his concerns if you still want this in.

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
maintainer
#8 lore raw
Quoted 75 lines · Jeff Layton
Quoted 73 lines · Xiubo Li
Quoted 60 lines · Ilya Dryomov
Quoted 59 lines · Xiubo Li
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
   fs/ceph/dir.c        | 2 +-
   fs/ceph/mds_client.c | 6 +++++-
   2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
          err = ceph_handle_snapdir(req, dentry, err);
          dentry = ceph_finish_lookup(req, dentry, err);
          ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
          return dentry;
   }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                  ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                    CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

Quoted 6 lines
Quoted 3 lines

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

I was reacting to ceph_mdsc_submit_request() hunk. Feel free to tweak ceph_lookup() or refactor it so that err is not threaded through three different functions as Jeff suggested.

Hi Ilya

Oh okay. You are right we can figure out what we need via many other dout logs.

Quoted 7 lines
Quoted 4 lines

I just saw some very confusing logs that the "dentry" in cpeh_lookup() and the "inode" in _submit_ are all 000000007a1ca695, so I addressed them both here.

Since Ilya objected to this patch, I'll drop it from testing for now. Please send a v2 that addresses his concerns if you still want this in.

I have submitted a patch to fix printk to not obfuscate NULL and error pointers and haven't heard any objections yet, so hopefully this issue will become moot soon.

Thanks,

Ilya

author
#9 lore raw
Quoted 78 lines · Ilya Dryomov
Quoted 77 lines · Jeff Layton
Quoted 76 lines · Xiubo Li
Quoted 60 lines · Ilya Dryomov
Quoted 59 lines · Xiubo Li
Quoted 47 lines · Ilya Dryomov
Quoted 32 lines · On Mon, Feb 17, 2020 at 12:28 PM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

For example, if dentry and inode is NULL, the log will be:

ceph:  lookup result=000000007a1ca695
ceph:  submit_request on 0000000041d5070e for inode 000000007a1ca695

The will be confusing without checking the corresponding code carefully.

---
    fs/ceph/dir.c        | 2 +-
    fs/ceph/mds_client.c | 6 +++++-
    2 files changed, 6 insertions(+), 2 deletions(-)
fs/ceph/dir.c +1 -1
index ffeaff5bf211..245a262ec198 100644
@@ -798,7 +798,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
           err = ceph_handle_snapdir(req, dentry, err);
           dentry = ceph_finish_lookup(req, dentry, err);
           ceph_mdsc_put_request(req);  /* will dput(dentry) */
-       dout("lookup result=%p\n", dentry);
+       dout("lookup result=%d\n", err);
           return dentry;
    }
 
fs/ceph/mds_client.c +0 -0
index b6aa357f7c61..e34f159d262b 100644

fs/ceph/mds_client.c int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir, · line 2778

Quoted 8 lines
fs/ceph/mds_client.c +4 -1
@@ -2772,7 +2772,11 @@ int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct inode *dir,
                   ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                     CEPH_CAP_PIN);
 
-       dout("submit_request on %p for inode %p\n", req, dir);
+       if (dir)
+               dout("submit_request on %p for inode %p\n", req, dir);
+       else
+               dout("submit_request on %p\n", req);

Hi Xiubo,

It's been this way for a couple of years now. There are a lot more douts in libceph, ceph and rbd that are sometimes fed NULL pointers. I don't think replacing them with conditionals is the way forward.

Quoted 5 lines

I honestly don't know what security concern is addressed by hashing NULL pointers, but that is what we have... Ultimately, douts are just for developers, and when you find yourself having to chase individual pointers, you usually have a large enough piece of log to figure out what the NULL hash is.

Hi Ilya

For the ceph_lookup(). The dentry will be NULL(when the directory exists or -ENOENT) or ERR_PTR(-errno) in most cases here, it seems for the rename case it will be the old dentry returned.

Quoted 6 lines
Quoted 3 lines

So today I was trying to debug and get some logs from it, the 000000007a1ca695 really confused me for a long time before I dig into the source code.

I was reacting to ceph_mdsc_submit_request() hunk. Feel free to tweak ceph_lookup() or refactor it so that err is not threaded through three different functions as Jeff suggested.

Hi Ilya

Oh okay. You are right we can figure out what we need via many other dout logs.

I just saw some very confusing logs that the "dentry" in cpeh_lookup() and the "inode" in _submit_ are all 000000007a1ca695, so I addressed them both here.

Quoted 5 lines
Quoted 2 lines

Since Ilya objected to this patch, I'll drop it from testing for now. Please send a v2 that addresses his concerns if you still want this in.

I have submitted a patch to fix printk to not obfuscate NULL and error pointers and haven't heard any objections yet, so hopefully this issue will become moot soon.

Hi Jeff, Ilya

Yeah, this is very cool for me. This will just work like the string pointer formating, if it is NULL it then will be formated as "null"/"nil" or something instead.

Thanks

BRs

Quoted 4 lines

Thanks,

Ilya