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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 23 Jul 2015 22:57:57 -0400
Nicholas Krause <xerofoify@xxxxxxxxx> 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@xxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux