Whamcloud - gitweb
LU-9897 utils: remove dependency on libblkid 10/36010/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 29 Aug 2019 07:46:24 +0000 (01:46 -0600)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Sep 2019 01:53:35 +0000 (01:53 +0000)
There was a weak dependency in llverdev on libblkid in order to
find the size of the underlying block device.  However, in the
absence of libblkid there is fallback code that can find the
block device size, so we don't really need libblkid at all.

Similarly, llverdev had a weak dependency on libext2fs to check
if the block device was currently in use, but all kernels since
v2.6.34-rc4-22-g6b4517a7913a allow using open(O_EXCL) to ensure
a block device is not mounted, so there is no need for llverdev
to depend on libext2fs for this.

Remove the conditional code depending on the external libraries
from llverdev and the corresponding configuration checks, which
were causing problems in various build environments.

Test-Parameters: trivial testlist=conf-sanity
Fixes: 6bc323747706 ("LU-9897 build: use pkgconf for detecting libblkid")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I90d2f0c99115ce07168c185dec6628be813ebbe5
Reviewed-on: https://review.whamcloud.com/36010
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/utils/Makefile.am
lustre/utils/llverdev.c

index 89e2141..68c61f3 100644 (file)
@@ -3199,11 +3199,6 @@ LC_MDS_MAX_THREADS
 AC_CHECK_HEADERS([netdb.h endian.h])
 AC_CHECK_FUNCS([gethostbyname])
 
-# lustre/utils/llverdev.c
-AS_IF([test "x$enable_dist" = xno], [
-       PKG_CHECK_MODULES(blkid, [blkid])
-])
-
 # lustre/utils/llverfs.c
 AC_CHECK_HEADERS([ext2fs/ext2fs.h])
 
@@ -3219,9 +3214,6 @@ AS_IF([test "$enable_dist" = "no"], [
 ])
 
 SELINUX=""
-AS_IF([test "x$enable_dist" = xno], [
-       PKG_CHECK_MODULES(blkid, [blkid])
-])
 
 AC_CHECK_LIB([selinux], [is_selinux_enabled],
        [AC_CHECK_HEADERS([selinux/selinux.h],
index 44ae523..11e2392 100644 (file)
@@ -90,7 +90,6 @@ EXT2FSLIB =
 endif
 
 llverfs_LDADD := $(EXT2FSLIB) $(E2PLIB)
-llverdev_LDADD := $(EXT2FSLIB) $(blkid_LIBS)
 
 liblustreapi_la_SOURCES = liblustreapi.c liblustreapi_hsm.c \
                          liblustreapi_nodemap.c lustreapi_internal.h \
index e05f41b..54e3499 100644 (file)
 #include <sys/time.h>
 #include <gnu/stubs.h>
 
-#ifdef HAVE_EXT2FS_EXT2FS_H
-#  include <ext2fs/ext2fs.h>
-#endif
-
 #define ONE_MB (1024 * 1024)
 #define ONE_GB (1024 * 1024 * 1024)
 #define HALF_MB (ONE_MB / 2)
@@ -157,23 +153,8 @@ void usage(int status)
  */
 static int open_dev(const char *devname, int mode)
 {
-       int     fd;
-#ifdef HAVE_EXT2FS_EXT2FS_H
-       int     mount_flags;
-       char    mountpt[80] = "";
-
-       if (ext2fs_check_mount_point(devname, &mount_flags, mountpt,
-                                    sizeof(mountpt))) {
-               fprintf(stderr, "%s: ext2fs_check_mount_point failed:%s",
-                       progname, strerror(errno));
-               exit(1);
-       }
-       if (mount_flags & EXT2_MF_MOUNTED){
-               fprintf(stderr, "%s: %s is already mounted\n", progname,
-                       devname);
-               exit(1);
-       }
-#endif
+       int fd;
+
        fd = open(devname, mode | O_EXCL | O_LARGEFILE);
        if (fd < 0) {
                fprintf(stderr, "%s: Open failed: %s",progname,strerror(errno));
@@ -182,25 +163,13 @@ static int open_dev(const char *devname, int mode)
        return fd;
 }
 
-#ifdef HAVE_BLKID_BLKID_H
-#include <blkid/blkid.h>
-#endif
 /*
  * sizeof_dev: Returns size of device in bytes
  */
-static loff_t sizeof_dev(int fd)
+static size_t sizeof_dev(int fd)
 {
-       loff_t numbytes;
+       size_t numbytes;
 
-#ifdef HAVE_BLKID_BLKID_H
-       numbytes = blkid_get_dev_size(fd);
-       if (numbytes <= 0) {
-               fprintf(stderr, "%s: blkid_get_dev_size(%s) failed",
-                       progname, devname);
-               return 1;
-       }
-       goto out;
-#else
 # if defined BLKGETSIZE64      /* in sys/mount.h */
        if (ioctl(fd, BLKGETSIZE64, &numbytes) >= 0)
                goto out;
@@ -226,7 +195,6 @@ static loff_t sizeof_dev(int fd)
        fprintf(stderr, "%s: unable to determine size of %s\n",
                progname, devname);
        return 0;
-#endif
 
 out:
        if (verbose)
@@ -583,10 +551,10 @@ int main(int argc, char **argv)
        if (!force && writeoption) {
                printf("%s: permanently overwrite all data on %s (yes/no)? ",
                       progname, devname);
-                if (scanf("%3s", yesno) == EOF && ferror(stdin)) {
-                        perror("reading from stdin");
-                        return -1;
-                }
+               if (scanf("%3s", yesno) == EOF && ferror(stdin)) {
+                       perror("reading from stdin");
+                       return -1;
+               }
                if (!(strcasecmp("yes", yesno) || strcasecmp("y", yesno))) {
                        printf("Not continuing due to '%s' response", yesno);
                        return 0;