[Devel,RH7] ms/tmpfs: fix SEEK_DATA/SEEK_HOLE regression

Submitted by Pavel Tikhomirov on Nov. 3, 2016, 12:03 p.m.

Details

Message ID 1478174614-28359-1-git-send-email-ptikhomirov@virtuozzo.com
State New
Series "ms/tmpfs: fix SEEK_DATA/SEEK_HOLE regression"
Headers show

Commit Message

Pavel Tikhomirov Nov. 3, 2016, 12:03 p.m.
From: Hugh Dickins <hughd@google.com>

Fixes a problem in shmem criu test and friends on VZ7 after criu
commit 51554fa59eed ("shmem: use lseek(SEEK_DATA) instead of mincore"):

https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/branch/criu-dev/861/

Patch hide | download patch | download mbox

============ Run zdtm/transition/shmem in h ===============
Start test
./shmem --pidfile=shmem.pid --outfile=shmem.out
Run criu dump
=[log]=> dump/zdtm/transition/shmem/24/1/dump.log
------------------------ grep Error ------------------------
(00.075066) Error (criu/shmem.c:648): Unable to lseek(SEEK_DATA):
Invalid argument
(00.075302) Error (criu/cr-dump.c:1682): Dumping FAILED.
------------------------ ERROR OVER ------------------------

  Commit 46a1c2c7ae53 ("vfs: export lseek_execute() to modules") broke the
  tmpfs SEEK_DATA/SEEK_HOLE implementation, because vfs_setpos() converts
  the carefully prepared -ENXIO to -EINVAL.  Other filesystems avoid it in
  error cases: do the same in tmpfs.

  Signed-off-by: Hugh Dickins <hughd@google.com>
  Cc: Jie Liu <jeff.liu@oracle.com>
  Cc: Al Viro <viro@zeniv.linux.org.uk>
  Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

https://jira.sw.ru/browse/PSBM-54804
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 mm/shmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 827347d..00d7273 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1897,7 +1897,8 @@  static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
 		}
 	}
 
-	offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
+	if (offset >= 0)
+		offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
 	mutex_unlock(&inode->i_mutex);
 	return offset;
 }

Comments

Andrey Vagin Nov. 3, 2016, 2:32 p.m.
On Thu, Nov 03, 2016 at 03:03:34PM +0300, Pavel Tikhomirov wrote:
> From: Hugh Dickins <hughd@google.com>
> 
> Fixes a problem in shmem criu test and friends on VZ7 after criu
> commit 51554fa59eed ("shmem: use lseek(SEEK_DATA) instead of mincore"):
>

Acked-by: Andrew Vagin <avagin@virtuozzo.com>

> https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/branch/criu-dev/861/
> ============ Run zdtm/transition/shmem in h ===============
> Start test
> ./shmem --pidfile=shmem.pid --outfile=shmem.out
> Run criu dump
> =[log]=> dump/zdtm/transition/shmem/24/1/dump.log
> ------------------------ grep Error ------------------------
> (00.075066) Error (criu/shmem.c:648): Unable to lseek(SEEK_DATA):
> Invalid argument
> (00.075302) Error (criu/cr-dump.c:1682): Dumping FAILED.
> ------------------------ ERROR OVER ------------------------
> 
>   Commit 46a1c2c7ae53 ("vfs: export lseek_execute() to modules") broke the
>   tmpfs SEEK_DATA/SEEK_HOLE implementation, because vfs_setpos() converts
>   the carefully prepared -ENXIO to -EINVAL.  Other filesystems avoid it in
>   error cases: do the same in tmpfs.
> 
>   Signed-off-by: Hugh Dickins <hughd@google.com>
>   Cc: Jie Liu <jeff.liu@oracle.com>
>   Cc: Al Viro <viro@zeniv.linux.org.uk>
>   Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> 
> https://jira.sw.ru/browse/PSBM-54804
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> ---
>  mm/shmem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 827347d..00d7273 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1897,7 +1897,8 @@ static loff_t shmem_file_llseek(struct file *file, loff_t offset, int whence)
>  		}
>  	}
>  
> -	offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
> +	if (offset >= 0)
> +		offset = vfs_setpos(file, offset, MAX_LFS_FILESIZE);
>  	mutex_unlock(&inode->i_mutex);
>  	return offset;
>  }
> -- 
> 2.7.4
>