diff mbox

[v2,1/3] Consolidate fallocate{64} implementations

Message ID 830f1b4e-b6a4-060c-acca-ad7b97b34964@linaro.org
State New
Headers show

Commit Message

Adhemerval Zanella Netto Oct. 17, 2016, 6:58 p.m. UTC
On 17/10/2016 13:57, Christoph Hellwig wrote:
> On Mon, Oct 17, 2016 at 05:52:12PM +0200, Andreas Schwab wrote:
>> The error is EOPNOTSUPP, virtio-blk apparently does not support
>> fallocate (neither does nfs).
> 
> virtio-blk is a block driver, it's the file system that needs to
> support it.  NFS 4.2 actually does support a subset of the fallocate
> functionality, but the spec isn't finished yet and thus usually
> not turned on by default.
> 
> That being said: EOPNOTSUPP is a common return value for fallocate
> and should be expected at any time.
> 

Right, I did not take in consideration that fallocate might fall due
this constraint. The correct approach would be just set as unsupported
if fallocate returns -1/EOPNOTSUPP. 

I will push this patch:

Comments

Florian Weimer Oct. 18, 2016, 9:55 a.m. UTC | #1
On 10/17/2016 08:58 PM, Adhemerval Zanella wrote:

> Right, I did not take in consideration that fallocate might fall due
> this constraint. The correct approach would be just set as unsupported
> if fallocate returns -1/EOPNOTSUPP.
>
> I will push this patch:

Okay with a suitable changelog entry for both sets of changes.

Thanks,
Florian
diff mbox

Patch

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 101e120..e329a6b 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -43,7 +43,7 @@  sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
                  bits/mman-linux.h
 
 tests += tst-clone tst-clone2 tst-fanotify tst-personality tst-quota \
-        tst-fallocate tst-fallocate64 tst-sync_file_range
+        tst-sync_file_range
 
 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
 
@@ -173,6 +173,8 @@  ifeq ($(subdir),io)
 sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
                   sync_file_range fallocate fallocate64
 sysdep_headers += bits/fcntl-linux.h
+
+tests += tst-fallocate tst-fallocate64
 endif
 
 ifeq ($(subdir),elf)
diff --git a/sysdeps/unix/sysv/linux/tst-fallocate-common.c b/sysdeps/unix/sysv/linux/tst-fallocate-common.c
index 9879488..d98bf4a 100644
--- a/sysdeps/unix/sysv/linux/tst-fallocate-common.c
+++ b/sysdeps/unix/sysv/linux/tst-fallocate-common.c
@@ -58,7 +58,13 @@  do_test_with_offset (off_t offset)
      and check if both buffer have the same contents.  */
   ret = fallocate (temp_fd, 0, offset, BLK_SIZE);
   if (ret == -1)
-    FAIL_EXIT1 ("fallocate failed");
+    {
+      /* fallocate might not be fully supported by underlying filesystem (for
+        instance some NFS versions).   */
+      if (errno == EOPNOTSUPP)
+       FAIL_EXIT (77, "fallocate not supported");
+      FAIL_EXIT1 ("fallocate failed");
+    }
 
   ret = fstat (temp_fd, &finfo);
   if (ret == -1)