diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2013-04-22 03:41:41 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-04-30 07:00:02 -0400 |
commit | b8d4a5bf6a049303a29a3275f463f09a490b50ea (patch) | |
tree | c9a87f8a6eb8a64d0c5b8304c80bc2c22407289c /kernel/relay.c | |
parent | ea56505bedd03e21f497c59cece15a62b4398fc4 (diff) |
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
blktrace_setup()
dir = create_dir()
rchan = relay_open(dir,...)
->create_buf_file_callback
buf_file = debugfs_create_file(dir, )
Userspace will open buf_file.
Later we make a decision to stop tracing
blktrace_down()
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.
user_space_close()
->file_release
->release_buf_file_callback
->debugfs_remove(buf_file
## TESTCASE:
# 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
buf_file.
Solution: We don't have to wait that long. File should be deleted inside
relay_close_buf().
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel/relay.c')
-rw-r--r-- | kernel/relay.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/relay.c b/kernel/relay.c index 01ab081ac53a..a0d200012adb 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -234,7 +234,6 @@ static void relay_destroy_buf(struct rchan_buf *buf) | |||
234 | static void relay_remove_buf(struct kref *kref) | 234 | static void relay_remove_buf(struct kref *kref) |
235 | { | 235 | { |
236 | struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref); | 236 | struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref); |
237 | buf->chan->cb->remove_buf_file(buf->dentry); | ||
238 | relay_destroy_buf(buf); | 237 | relay_destroy_buf(buf); |
239 | } | 238 | } |
240 | 239 | ||
@@ -484,6 +483,7 @@ static void relay_close_buf(struct rchan_buf *buf) | |||
484 | { | 483 | { |
485 | buf->finalized = 1; | 484 | buf->finalized = 1; |
486 | del_timer_sync(&buf->timer); | 485 | del_timer_sync(&buf->timer); |
486 | buf->chan->cb->remove_buf_file(buf->dentry); | ||
487 | kref_put(&buf->kref, relay_remove_buf); | 487 | kref_put(&buf->kref, relay_remove_buf); |
488 | } | 488 | } |
489 | 489 | ||