Whamcloud - gitweb
LU-2109 llog: introduce llog handle refcounter
llog handle is allocated by llog_open and freed by llog_close,
meawhile there is 'backdoor' to get already opened handle - it is
llog_cat_id2handle() function, it can find handle in the list. That
leads to possible use-after-free.
llog_refcount was introduced to solve this.
- llog_alloc_handle() set refcount to 1
- llog_handle_put() drops refcount and free handle if refcount == 0
- llog_cat_i2handle() takes extra reference
- llog_handle_put() must be called if handle was taken by
llog_cat_id2handle()
- llog_free_handle() calls llog_handle_put() at the end.
Additional changes in patch:
- llog_cat_init_and_process() processes llogs without fork, making
sure that server will not start until all old llogs are cancelled.
- llog_cat_cancel_records() doesn't break cycle if handle is not
found but continue to check other handles
- wrong GOTO() parameter in llog_close. Should be 'rc = -EOPNOTSUPP'
but not just '-EOPNOTSUPP'.
- indentation fixes.
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: I0dd0a934eb79c63c6726902540132ad877183d10
Reviewed-on: http://review.whamcloud.com/4745
Tested-by: Hudson
Reviewed-by: Li Wei <wei.g.li@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Prakash Surya <surya1@llnl.gov>