Commit b8d4a5bf authored by Dmitry Monakhov's avatar Dmitry Monakhov Committed by Jens Axboe

relay: move remove_buf_file inside relay_close_buf

Currently remove_buf_file callback is called from from kobject
release method. This result in follow issue:
# blktrace -d /dev/sda1 -d /dev/sda -o test

 dir = create_dir()
 rchan = relay_open(dir,...)
    buf_file  = debugfs_create_file(dir, )

Userspace will open buf_file.
Later we make a decision to stop tracing
  relay_close(rhcan)  /* just decrement kobj reference  */
                      /* since it is not zero then callback not called */
  debugfs_remove(dir) /* FAIL due to non empty dir   */

Later user space will close the file and file will be deleted,
but directory still exist.
# blktrace -d /dev/sda1 -d /dev/sda -o test
# After that blktrace infrastructure will remain broken in
# an unusable state so: blktrace -d /dev/sda1 will not work.

In fact this is general issue, blktrace is just one of examples.
We can not reliably remove parent dir until all users close the

Solution: We don't have to wait that long. File should be deleted inside
Signed-off-by: 's avatarDmitry Monakhov <>
Signed-off-by: 's avatarJens Axboe <>
parent ea56505b
......@@ -234,7 +234,6 @@ static void relay_destroy_buf(struct rchan_buf *buf)
static void relay_remove_buf(struct kref *kref)
struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
......@@ -484,6 +483,7 @@ static void relay_close_buf(struct rchan_buf *buf)
buf->finalized = 1;
kref_put(&buf->kref, relay_remove_buf);
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