* Re: [PATCH] fs:Fix error handling in the function time_out_leases
[not found] <1437706677-4386-1-git-send-email-xerofoify@gmail.com>
@ 2015-07-24 10:16 ` Jeff Layton
0 siblings, 0 replies; only message in thread
From: Jeff Layton @ 2015-07-24 10:16 UTC (permalink / raw)
To: Nicholas Krause; +Cc: viro, bfields, linux-fsdevel, linux-kernel
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>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-24 10:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1437706677-4386-1-git-send-email-xerofoify@gmail.com>
2015-07-24 10:16 ` [PATCH] fs:Fix error handling in the function time_out_leases Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).