[1/1] locks: skip 'lease correction' for non-regular files

Submitted by Pavel Begunkov (Silence) on Oct. 21, 2017, 2:15 p.m.

Details

Message ID 20171021141559.16191-1-asml.silence@gmail.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Pavel Begunkov (Silence) Oct. 21, 2017, 2:15 p.m.
From: Pavel Begunkov <asml.silence@gmail.com>

Leases can be set only on regular files. Thus, as optimization we can
skip attempts to find associated leases in 'correct_file_leases_type'
for other fd types.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 criu/files.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index 977d65cb..a62b5405 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -488,8 +488,12 @@  static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
 	if (note_file_lock(pid, fd, lfd, &p))
 		return -1;
 
-	if (correct_file_leases_type(pid, fd, lfd))
-		return -1;
+	if (S_ISREG(p.stat.st_mode)) {
+		int ret = correct_file_leases_type(pid, fd, lfd);
+
+		if (ret < 0)
+			return ret;
+	}
 
 	p.fd_ctl = ctl; /* Some dump_opts require this to talk to parasite */
 

Comments

Andrey Vagin Nov. 8, 2017, 8:35 p.m.
On Sat, Oct 21, 2017 at 05:15:59PM +0300, asml.silence@gmail.com wrote:
> From: Pavel Begunkov <asml.silence@gmail.com>
> 
> Leases can be set only on regular files. Thus, as optimization we can
> skip attempts to find associated leases in 'correct_file_leases_type'
> for other fd types.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  criu/files.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/files.c b/criu/files.c
> index 977d65cb..a62b5405 100644
> --- a/criu/files.c
> +++ b/criu/files.c
> @@ -488,8 +488,12 @@ static int dump_one_file(struct pid *pid, int fd, int lfd, struct fd_opts *opts,
>  	if (note_file_lock(pid, fd, lfd, &p))
>  		return -1;
>  
> -	if (correct_file_leases_type(pid, fd, lfd))
> -		return -1;
> +	if (S_ISREG(p.stat.st_mode)) {

pls add a comment here.

> +		int ret = correct_file_leases_type(pid, fd, lfd);
> +
> +		if (ret < 0)
> +			return ret;
> +	}
>  
>  	p.fd_ctl = ctl; /* Some dump_opts require this to talk to parasite */
>  
> -- 
> 2.14.1.473.g3ec7d702a8
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu