- Nov 24, 2023
-
-
Kent Overstreet authored
Control flow integrity is now checking that type signatures match on indirect function calls. That breaks closures, which embed a work_struct in a closure in such a way that a closure_fn may also be used as a workqueue fn by the underlying closure code. So we have to change closure fns to take a work_struct as their argument - but that results in a loss of clarity, as closure fns have different semantics from normal workqueue functions (they run owning a ref on the closure, which must be released with continue_at() or closure_return()). Thus, this patc introduces CLOSURE_CALLBACK() and closure_type() macros as suggested by Kees, to smooth things over a bit. Suggested-by:
Kees Cook <keescook@chromium.org> Cc: Coly Li <colyli@suse.de> Signed-off-by:
Kent Overstreet <kent.overstreet@linux.dev>
-
- Oct 31, 2023
-
-
Kent Overstreet authored
As pointed out by Linus, closure_sync() was racy; we could skip blocking immediately after a get() and a put(), but then that would skip any barrier corresponding to the other thread's put() barrier. To fix this, always do the full __closure_sync() sequence whenever any get() has happened and the closure might have been used by other threads. Signed-off-by:
Kent Overstreet <kent.overstreet@linux.dev>
-
Kent Overstreet authored
atomic_(dec|sub)_return_release() are a thing now - use them. Also, delete the useless barrier in set_closure_fn(): it's redundant with the memory barrier in closure_put(0. Since closure_put() would now otherwise just have a release barrier, we also need a new barrier when the ref hits 0 - smp_acquire__after_ctrl_dep(). Signed-off-by:
Kent Overstreet <kent.overstreet@linux.dev>
-
- Oct 19, 2023
-
-
Kent Overstreet authored
Fixes building in userspace. Signed-off-by:
Kent Overstreet <kent.overstreet@linux.dev>
-
Kent Overstreet authored
Prep work for bcachefs - being a fork of bcache it also uses closures Signed-off-by:
Kent Overstreet <kent.overstreet@linux.dev> Acked-by:
Coly Li <colyli@suse.de> Reviewed-by:
Randy Dunlap <rdunlap@infradead.org>
-
- Oct 02, 2020
-
-
Qinglang Miao authored
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. As inode->iprivate equals to third parameter of debugfs_create_file() which is NULL. So it's equivalent to original code logic. Signed-off-by:
Qinglang Miao <miaoqinglang@huawei.com> Signed-off-by:
Coly Li <colyli@suse.de> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Nov 13, 2019
-
-
Christoph Hellwig authored
None of the exported bcache symbols are actually used anywhere. Signed-off-by:
Christoph Hellwig <hch@lst.de> Signed-off-by:
Coly Li <colyli@suse.de> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Sep 03, 2019
-
-
Kent Overstreet authored
The race was when a thread using closure_sync() notices cl->s->done == 1 before the thread calling closure_put() calls wake_up_process(). Then, it's possible for that thread to return and exit just before wake_up_process() is called - so we're trying to wake up a process that no longer exists. rcu_read_lock() is sufficient to protect against this, as there's an rcu barrier somewhere in the process teardown path. Signed-off-by:
Kent Overstreet <kent.overstreet@gmail.com> Acked-by:
Coly Li <colyli@suse.de> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Aug 11, 2018
-
-
Coly Li authored
The SPDX header is missing fro closure.c, super.c and util.c, this patch adds SPDX header for GPL-2.0 into these files. Signed-off-by:
Coly Li <colyli@suse.de> Reviewed-by:
Shenghui Wang <shhuiw@foxmail.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
Coly Li authored
'%pF' and '%pf' are deprecated vsprintf pointer extensions, this patch replace them by '%pS', which is suggested by checkpatch.pl. Signed-off-by:
Coly Li <colyli@suse.de> Reviewed-by:
Shenghui Wang <shhuiw@foxmail.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
Coly Li authored
Signed-off-by:
Coly Li <colyli@suse.de> Reviewed-by:
Shenghui Wang <shhuiw@foxmail.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Aug 09, 2018
-
-
Coly Li authored
Greg KH suggests that normal code should not care about debugfs. Therefore no matter successful or failed of debugfs_create_dir() execution, it is unncessary to check its return value. There are two functions called debugfs_create_dir() and check the return value, which are bch_debug_init() and closure_debug_init(). This patch changes these two functions from int to void type, and ignore return values of debugfs_create_dir(). This patch does not fix exact bug, just makes things work as they should. Signed-off-by:
Coly Li <colyli@suse.de> Suggested-by:
Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: stable@vger.kernel.org Cc: Kai Krakow <kai@kaishome.de> Cc: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Mar 19, 2018
-
-
Bart Van Assche authored
Avoid that building with W=1 triggers warnings about the kernel-doc headers. Signed-off-by:
Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by:
Michael Lyle <mlyle@lyle.org> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
Chengguang Xu authored
In current code closure debug file is outside of debug directory and when unloading module there is lack of removing operation for closure debug file, so it will cause creating error when trying to reload module. This patch move closure debug file into "bcache" debug direcory so that the file can get deleted properly. Signed-off-by:
Chengguang Xu <cgxu519@gmx.com> Reviewed-by:
Michael Lyle <mlyle@lyle.org> Reviewed-by:
Tang Junhui <tang.junhui@zte.com.cn> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Jan 08, 2018
-
-
Kent Overstreet authored
[edit by mlyle: include sched/debug.h to get __sched] Signed-off-by:
Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by:
Michael Lyle <mlyle@lyle.org> Reviewed-by:
Michael Lyle <mlyle@lyle.org> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
Kent Overstreet authored
Eliminates cases where sync can race and fail to complete / get stuck. Removes many status flags and simplifies entering-and-exiting closure sleeping behaviors. [mlyle: fixed conflicts due to changed return behavior in mainline. extended commit comment, and squashed down two commits that were mostly contradictory to get to this state. Changed __set_current_state to set_current_state per Jens review comment] Signed-off-by:
Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by:
Michael Lyle <mlyle@lyle.org> Reviewed-by:
Michael Lyle <mlyle@lyle.org> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Sep 27, 2017
-
-
Coly Li authored
Commit 09b3efec ("bcache: Don't reinvent the wheel but use existing llist API") replaces the following while loop by llist_for_each_entry(), - - while (reverse) { - cl = container_of(reverse, struct closure, list); - reverse = llist_next(reverse); - + llist_for_each_entry(cl, reverse, list) { closure_set_waiting(cl, 0); closure_sub(cl, CLOSURE_WAITING + 1); } This modification introduces a potential race by iterating a corrupted list. Here is how it happens. In the above modification, closure_sub() may wake up a process which is waiting on reverse list. If this process decides to wait again by calling closure_wait(), its cl->list will be added to another wait list. Then when llist_for_each_entry() continues to iterate next node, it will travel on another new wait list which is added in closure_wait(), not the original reverse list in __closure_wake_up(). It is more probably to happen on UP machine because the waked up process may preempt the process which wakes up it. Use llist_for_each_entry_safe() will fix the issue, the safe version fetch next node before waking up a process. Then the copy of next node will make sure list iteration stays on original reverse list. Fixes: 09b3efec ("bcache: Don't reinvent the wheel but use existing llist API") Signed-off-by:
Coly Li <colyli@suse.de> Reported-by:
Michael Lyle <mlyle@lyle.org> Reviewed-by:
Byungchul Park <byungchul.park@lge.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Sep 06, 2017
-
-
Byungchul Park authored
Although llist provides proper APIs, they are not used. Make them used. Signed-off-by:
Byungchul Park <byungchul.park@lge.com> Acked-by:
Coly Li <colyli@suse.de> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Jul 05, 2016
-
-
Yijing Wang authored
There is no return in continue_at(), update the documentation. Signed-off-by:
Yijing Wang <wangyijing@huawei.com> Acked-by:
Coly Li <colyli@suse.de> Signed-off-by:
Jens Axboe <axboe@fb.com>
-
- Nov 06, 2015
-
-
Petr Mladek authored
WORK_STRUCT_PENDING is a mask for testing the pending bit. test_bit() expects the number of the bit and we need to use WORK_STRUCT_PENDING_BIT there. Also work_data_bits() is defined in workqueues.h now. I have noticed this just by chance when looking how WORK_STRUCT_PENDING_BIT is used. The change is compile tested. Signed-off-by:
Petr Mladek <pmladek@suse.com> Signed-off-by:
Jiri Kosina <jkosina@suse.cz>
-
- Jan 08, 2014
-
-
Kent Overstreet authored
Also flesh out the documentation a bit Signed-off-by:
Kent Overstreet <kmo@daterainc.com>
-
- Nov 11, 2013
-
-
Kent Overstreet authored
With a the recent bcache refactoring, some of the closure code isn't needed anymore. Signed-off-by:
Kent Overstreet <kmo@daterainc.com>
-
- Jul 12, 2013
-
-
Kent Overstreet authored
In the far-too-complicated closure code - closures can have destructors, for probably dubious reasons; they get run after the closure is no longer waiting on anything but before dropping the parent ref, intended just for freeing whatever memory the closure is embedded in. Trouble is, when remaining goes to 0 and we've got nothing more to run - we also have to unlock the closure, setting remaining to -1. If there's a destructor, that unlock isn't doing anything - nobody could be trying to lock it if we're about to free it - but if the unlock _is needed... that check for a destructor was racy. Argh. Signed-off-by:
Kent Overstreet <kmo@daterainc.com> Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
-
- Mar 26, 2013
-
-
Kent Overstreet authored
Commit 82a84eaf7e51ba3da0c36cbc401034a4e943492d left a return 0 in closure_debug_init(). Whoops. Signed-off-by:
Kent Overstreet <koverstreet@google.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Mar 25, 2013
-
-
Kent Overstreet authored
config: make ARCH=i386 allmodconfig All error/warnings: drivers/md/bcache/bset.c: In function 'bch_ptr_bad': >> drivers/md/bcache/bset.c:164:2: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'size_t' [-Wformat] -- drivers/md/bcache/debug.c: In function 'bch_pbtree': >> drivers/md/bcache/debug.c:86:4: warning: format '%li' expects argument of type 'long int', but argument 4 has type 'size_t' [-Wformat] -- drivers/md/bcache/btree.c: In function 'bch_btree_read_done': >> drivers/md/bcache/btree.c:245:8: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' [-Wformat] -- drivers/md/bcache/closure.o: In function `closure_debug_init': >> (.init.text+0x0): multiple definition of `init_module' >> drivers/md/bcache/super.o:super.c:(.init.text+0x0): first defined here Signed-off-by:
Kent Overstreet <koverstreet@google.com> Cc: Fengguang Wu <fengguang.wu@intel.com> Cc: linux-bcache@vger.kernel.org Signed-off-by:
Jens Axboe <axboe@kernel.dk>
-
- Mar 23, 2013
-
-
Kent Overstreet authored
Does writethrough and writeback caching, handles unclean shutdown, and has a bunch of other nifty features motivated by real world usage. See the wiki at http://bcache.evilpiepirate.org for more. Signed-off-by:
Kent Overstreet <koverstreet@google.com>
-