From: "Serge E. Hallyn" <serge@hallyn.com>
To: ntl@pobox.com
Cc: linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org
Subject: Re: [PATCH 03/10] Introduce has_locks_with_owner() helper
Date: Sun, 3 Apr 2011 13:55:29 -0500 [thread overview]
Message-ID: <20110403185529.GB15044@hallyn.com> (raw)
In-Reply-To: <1298936432-29607-4-git-send-email-ntl@pobox.com>
Quoting ntl@pobox.com (ntl@pobox.com):
> From: Nathan Lynch <ntl@pobox.com>
>
> Support for file locks is in the works, but until that is done
> checkpoint needs to fail when an open file has locks.
>
> Based on original "find_locks_with_owner" patch by Dave Hansen.
>
> Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
> [ntl: changed name and return type to clearly express semantics]
> Signed-off-by: Nathan Lynch <ntl@pobox.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
> ---
> fs/locks.c | 35 +++++++++++++++++++++++++++++++++++
> include/linux/fs.h | 6 ++++++
> 2 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 8729347..961e17f 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -2037,6 +2037,41 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
>
> EXPORT_SYMBOL(locks_remove_posix);
>
> +bool has_locks_with_owner(struct file *filp, fl_owner_t owner)
> +{
> + struct inode *inode = filp->f_path.dentry->d_inode;
> + struct file_lock **inode_fl;
> + bool ret = false;
> +
> + lock_flocks();
> + for_each_lock(inode, inode_fl) {
> + struct file_lock *fl = *inode_fl;
> + /*
> + * We could use posix_same_owner() along with a 'fake'
> + * file_lock. But, the fake file will never have the
> + * same fl_lmops as the fl that we are looking for and
> + * posix_same_owner() would just fall back to this
> + * check anyway.
> + */
> + if (IS_POSIX(fl)) {
> + if (fl->fl_owner == owner) {
> + ret = true;
> + break;
> + }
> + } else if (IS_FLOCK(fl) || IS_LEASE(fl)) {
> + if (fl->fl_file == filp) {
> + ret = true;
> + break;
> + }
> + } else {
> + WARN(1, "unknown file lock type, fl_flags: %x",
> + fl->fl_flags);
> + }
> + }
> + unlock_flocks();
> + return ret;
> +}
> +
> /*
> * This function is called on the last close of an open file.
> */
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 090f0ea..315ded4 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1138,6 +1138,7 @@ extern void locks_remove_posix(struct file *, fl_owner_t);
> extern void locks_remove_flock(struct file *);
> extern void locks_release_private(struct file_lock *);
> extern void posix_test_lock(struct file *, struct file_lock *);
> +extern bool has_locks_with_owner(struct file *filp, fl_owner_t owner);
> extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
> extern int posix_lock_file_wait(struct file *, struct file_lock *);
> extern int posix_unblock_lock(struct file *, struct file_lock *);
> @@ -1208,6 +1209,11 @@ static inline void locks_remove_posix(struct file *filp, fl_owner_t owner)
> return;
> }
>
> +static inline bool has_locks_with_owner(struct file *filp, fl_owner_t owner)
> +{
> + return false;
> +}
> +
> static inline void locks_remove_flock(struct file *filp)
> {
> return;
> --
> 1.7.4
>
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
next prev parent reply other threads:[~2011-04-03 18:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 23:40 [RFC 00/10] container-based checkpoint/restart prototype ntl
2011-02-28 23:40 ` [PATCH 01/10] Make exec_mmap extern ntl
2011-04-03 16:56 ` Serge E. Hallyn
2011-02-28 23:40 ` [PATCH 02/10] Introduce mm_has_pending_aio() helper ntl
2011-03-01 15:40 ` Jeff Moyer
2011-03-01 16:04 ` Nathan Lynch
2011-02-28 23:40 ` [PATCH 03/10] Introduce has_locks_with_owner() helper ntl
2011-04-03 18:55 ` Serge E. Hallyn [this message]
2011-02-28 23:40 ` [PATCH 04/10] Introduce vfs_fcntl() helper ntl
2011-04-03 18:57 ` Serge E. Hallyn
2011-02-28 23:40 ` [PATCH 05/10] Core checkpoint/restart support code ntl
2011-04-03 19:03 ` Serge E. Hallyn
2011-04-04 15:00 ` Nathan Lynch
2011-04-04 15:10 ` Serge E. Hallyn
2011-04-04 15:40 ` Nathan Lynch
2011-04-04 16:27 ` Serge E. Hallyn
2011-04-04 17:32 ` Oren Laadan
2011-04-04 21:43 ` Nathan Lynch
2011-04-04 22:03 ` Serge E. Hallyn
2011-04-04 23:42 ` Dan Smith
2011-04-05 2:17 ` Serge E. Hallyn
2011-04-05 19:18 ` Nathan Lynch
2011-04-04 22:29 ` Matt Helsley
2011-04-04 17:41 ` Andrew Morton
2011-04-04 18:51 ` Serge E. Hallyn
2011-04-04 19:42 ` Andrew Morton
2011-04-04 20:29 ` Serge E. Hallyn
2011-04-04 21:55 ` Matt Helsley
2011-04-04 23:15 ` Andrew Morton
2011-04-04 23:16 ` Valdis.Kletnieks
2011-04-04 23:43 ` Matt Helsley
2011-04-04 22:11 ` Serge E. Hallyn
2011-04-04 22:53 ` Serge E. Hallyn
2011-04-04 21:20 ` Nathan Lynch
2011-04-04 21:53 ` Serge E. Hallyn
2011-02-28 23:40 ` [PATCH 06/10] Checkpoint/restart mm support ntl
2011-02-28 23:40 ` [PATCH 07/10] Checkpoint/restart vfs support ntl
2011-02-28 23:40 ` [PATCH 08/10] Add generic '->checkpoint' f_op to ext filesystems ntl
2011-02-28 23:40 ` [PATCH 09/10] Add generic '->checkpoint()' f_op to simple char devices ntl
2011-02-28 23:40 ` [PATCH 10/10] x86_32 support for checkpoint/restart ntl
2011-03-01 1:08 ` [RFC 00/10] container-based checkpoint/restart prototype Nathan Lynch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110403185529.GB15044@hallyn.com \
--to=serge@hallyn.com \
--cc=containers@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntl@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome