From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sukadev Bhattiprolu Subject: [PATCH 11/17][cr][v4]: Add ->fl_type_prev field. Date: Mon, 16 Aug 2010 12:43:15 -0700 Message-ID: <1281987801-1293-12-git-send-email-sukadev@linux.vnet.ibm.com> References: <1281987801-1293-1-git-send-email-sukadev@linux.vnet.ibm.com> Cc: Serge Hallyn , Matt Helsley , Dan Smith , John Stultz , Matthew Wilcox , Jamie Lokier , Steven Whitehouse , , Containers To: Oren Laadan Return-path: Received: from e8.ny.us.ibm.com ([32.97.182.138]:47215 "EHLO e8.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756357Ab0HPThx (ORCPT ); Mon, 16 Aug 2010 15:37:53 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e8.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o7GJKE3b018855 for ; Mon, 16 Aug 2010 15:20:14 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7GJbneP286276 for ; Mon, 16 Aug 2010 15:37:49 -0400 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o7GJbhLe015581 for ; Mon, 16 Aug 2010 13:37:45 -0600 In-Reply-To: <1281987801-1293-1-git-send-email-sukadev@linux.vnet.ibm.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: In preparation for checkpoint/restart of file leases, add ->fl_type_prev field to 'struct file_lock'. This field is needed to correctly restore file leases in case of recursive checkpoint/restart of an in-progress lease. This ->fl_type_prev is only initialized in this patch. It will actually be used when restoring file leases after a checkpoint. Signed-off-by: Sukadev Bhattiprolu --- fs/locks.c | 10 ++++++++++ include/linux/fs.h | 1 + 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 0bd5af7..9a00876 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -184,6 +184,7 @@ void locks_init_lock(struct file_lock *fl) fl->fl_file = NULL; fl->fl_flags = 0; fl->fl_type = 0; + fl->fl_type_prev = 0; fl->fl_start = fl->fl_end = 0; fl->fl_break_time = 0UL; fl->fl_ops = NULL; @@ -227,6 +228,7 @@ void __locks_copy_lock(struct file_lock *new, const struct file_lock *fl) new->fl_file = NULL; new->fl_flags = fl->fl_flags; new->fl_type = fl->fl_type; + new->fl_type_prev = fl->fl_type_prev; new->fl_start = fl->fl_start; new->fl_end = fl->fl_end; new->fl_break_time = 0UL; @@ -293,6 +295,13 @@ static int assign_type(struct file_lock *fl, int type) case F_WRLCK: case F_UNLCK: fl->fl_type = type; + /* + * Clear ->fl_type_prev since this is a new lease type. + * break_lease() will use this cleared state to know + * if it must save the lease-type in case of checkpoint/ + * restart. + */ + fl->fl_type_prev = 0; break; default: return -EINVAL; @@ -1222,6 +1231,7 @@ int __break_lease(struct inode *inode, unsigned int mode) for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) { if (fl->fl_type != future) { + fl->fl_type_prev = fl->fl_type; fl->fl_type = future; fl->fl_break_time = break_time; /* lease must have lmops break callback */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 49d4eeb..299cc09 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1066,6 +1066,7 @@ struct file_lock { fl_owner_t fl_owner; unsigned char fl_flags; unsigned char fl_type; + unsigned char fl_type_prev; unsigned int fl_pid; struct pid *fl_nspid; wait_queue_head_t fl_wait; -- 1.6.0.4