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

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Nov 3 05:03:34 PDT 2016


From: Hugh Dickins <hughd at 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/
============ 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 at google.com>
  Cc: Jie Liu <jeff.liu at oracle.com>
  Cc: Al Viro <viro at zeniv.linux.org.uk>
  Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>

https://jira.sw.ru/browse/PSBM-54804
Signed-off-by: Pavel Tikhomirov <ptikhomirov at 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



More information about the Devel mailing list