[PATCH 16/23] libfrog: make platform_set_blocksize exit on fatal failure

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

 



platform_set_blocksize has a fatal argument that is currently only
used to change the printed message.  Make it actually fatal similar to
other libfrog platform helpers to simplify the caller.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 libfrog/linux.c    | 27 +++++++++++++++------------
 libfrog/platform.h |  4 ++--
 libxfs/init.c      | 15 ++++++---------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/libfrog/linux.c b/libfrog/linux.c
index 2e4fd316e..46a5ff39e 100644
--- a/libfrog/linux.c
+++ b/libfrog/linux.c
@@ -127,20 +127,23 @@ platform_check_iswritable(char *name, char *block, struct stat *s)
 	return platform_check_mount(name, block, s, flags);
 }
 
-int
-platform_set_blocksize(int fd, char *path, dev_t device, int blocksize, int fatal)
+void
+platform_set_blocksize(int fd, char *path, dev_t device, int blocksize,
+		bool fatal)
 {
-	int error = 0;
-
-	if (major(device) != RAMDISK_MAJOR) {
-		if ((error = ioctl(fd, BLKBSZSET, &blocksize)) < 0) {
-			fprintf(stderr, _("%s: %s - cannot set blocksize "
-					"%d on block device %s: %s\n"),
-				progname, fatal ? "error": "warning",
-				blocksize, path, strerror(errno));
-		}
+	int error;
+
+	if (major(device) == RAMDISK_MAJOR)
+		return;
+	error = ioctl(fd, BLKBSZSET, &blocksize);
+	if (error < 0) {
+		fprintf(stderr, _("%s: %s - cannot set blocksize "
+				"%d on block device %s: %s\n"),
+			progname, fatal ? "error": "warning",
+			blocksize, path, strerror(errno));
+		if (fatal)
+			exit(1);
 	}
-	return error;
 }
 
 /*
diff --git a/libfrog/platform.h b/libfrog/platform.h
index e3e6b7c71..20f9bdf5c 100644
--- a/libfrog/platform.h
+++ b/libfrog/platform.h
@@ -10,8 +10,8 @@
 int platform_check_ismounted(char *path, char *block, struct stat *sptr,
 		int verbose);
 int platform_check_iswritable(char *path, char *block, struct stat *sptr);
-int platform_set_blocksize(int fd, char *path, dev_t device, int bsz,
-		int fatal);
+void platform_set_blocksize(int fd, char *path, dev_t device, int bsz,
+		bool fatal);
 int platform_flush_device(int fd, dev_t device);
 int platform_direct_blockdev(void);
 int platform_align_blockdev(void);
diff --git a/libxfs/init.c b/libxfs/init.c
index 6570c595a..5be6f8cf1 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -125,15 +125,12 @@ retry:
 	}
 
 	if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK) {
-		if (dio) {
-			/* try to use the given explicit blocksize */
-			(void)platform_set_blocksize(fd, path, statb.st_rdev,
-					setblksize, 0);
-		} else {
-			/* given an explicit blocksize to use */
-			if (platform_set_blocksize(fd, path, statb.st_rdev, setblksize, 1))
-			    exit(1);
-		}
+		/*
+		 * Try to use the given explicit blocksize.  Failure to set the
+		 * block size is only fatal for direct I/O.
+		 */
+		platform_set_blocksize(fd, path, statb.st_rdev, setblksize,
+				dio);
 	}
 
 	/*
-- 
2.39.2





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux