Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1191682 > unrolled thread

Re: [PATCH] fs:Fix error handling in the function time_out_leases

Started byJeff Layton <jlayton@poochiereds.net>
First post2015-07-24 12:20 +0200
Last post2015-07-24 12:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] fs:Fix error handling in the function time_out_leases Jeff Layton <jlayton@poochiereds.net> - 2015-07-24 12:20 +0200

#1191682 — Re: [PATCH] fs:Fix error handling in the function time_out_leases

FromJeff Layton <jlayton@poochiereds.net>
Date2015-07-24 12:20 +0200
SubjectRe: [PATCH] fs:Fix error handling in the function time_out_leases
Message-ID<pPIf9-2Nv-29@gated-at.bofh.it>
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>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web