[PATCH 11/14] btrfs-progs: check return of posix_fadvise

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems highly unlikely that posix_fadvise could fail,
and even if it does, it was only advisory.  Still, if
it does, we could issue a notice to the user.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 disk-io.c |    6 ++++--
 volumes.c |    3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/disk-io.c b/disk-io.c
index 897d0cf..97fbfbd 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -822,7 +822,8 @@ static struct btrfs_fs_info *__open_ctree_fd(int fp, const char *path,
 		sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
 
 	/* try to drop all the caches */
-	posix_fadvise(fp, 0, 0, POSIX_FADV_DONTNEED);
+	if (posix_fadvise(fp, 0, 0, POSIX_FADV_DONTNEED))
+		fprintf(stderr, "Warning, could not drop caches\n");
 
 	ret = btrfs_scan_one_device(fp, path, &fs_devices,
 				    &total_devs, sb_bytenr);
@@ -1282,7 +1283,8 @@ static int close_all_devices(struct btrfs_fs_info *fs_info)
 		device = list_entry(next, struct btrfs_device, dev_list);
 		if (device->fd) {
 			fsync(device->fd);
-			posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED);
+			if (posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED))
+				fprintf(stderr, "Warning, could not drop caches\n");
 		}
 		close(device->fd);
 	}
diff --git a/volumes.c b/volumes.c
index ca1b402..c0d02d1 100644
--- a/volumes.c
+++ b/volumes.c
@@ -193,7 +193,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, int flags)
 			goto fail;
 		}
 
-		posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
+		if (posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED))
+			fprintf(stderr, "Warning, could not drop caches\n");
 
 		if (device->devid == fs_devices->latest_devid)
 			fs_devices->latest_bdev = fd;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux