lkml.org 
[lkml]   [2015]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs:Fix error handling in the function time_out_leases
On Thu, 23 Jul 2015 22:57:57 -0400
Nicholas Krause <xerofoify@gmail.com> wrote:

> This fixes error handling in the function time_out_leases by
> checking if the call to the function lease_modify failed in
> both if statements in this function by checking its return
> value for a error code and if so print to the console that
> modifying the file lock's lease has failed on the inode
> pointer argument befor returning immediately to this function's
> caller as we cannot continue here.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> fs/locks.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index d3d558b..779754a 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1341,10 +1341,18 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose)
>
> list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) {
> trace_time_out_leases(inode, fl);
> - if (past_time(fl->fl_downgrade_time))
> - lease_modify(fl, F_RDLCK, dispose);
> - if (past_time(fl->fl_break_time))
> - lease_modify(fl, F_UNLCK, dispose);

lease_modify will only fail if the "arg" that it's passed is bogus, and
that's clearly not the case in these callers. What might be better is
to make a lease_modify variant that's a void return and that throws a
WARN when "arg" is bad.

I'd suggest just making lease_modify itself a void return, but it's
also the stock lm_change callback, and that prototype requires an int
return function.

> + if (past_time(fl->fl_downgrade_time)) {
> + if (lease_modify(fl, F_RDLCK, dispose)) {
> + pr_err("Unable to modify lease on %p\n file lock\n", fl);

A couple of nits here: printing out the pointer value won't generally be
helpful in an ERR level log message. Also, there's no need to embed a
newline in the middle of the message. That can make for an ugly log
message in syslog or the equivalent.

> + return;
> + }
> + }
> + if (past_time(fl->fl_break_time)) {
> + if (lease_modify(fl, F_UNLCK, dispose)) {
> + pr_err("Unable to modify lease on
> %p\n file lock\n", fl);
> + return;
> + }
> + }
> }
> }
>

--
Jeff Layton <jlayton@poochiereds.net>


\
 
 \ /
  Last update: 2015-07-24 12:21    [W:0.083 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site