]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Avoid using BLKFLSBUF.
authorNeilBrown <neilb@suse.de>
Tue, 5 Feb 2013 04:34:17 +0000 (15:34 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 5 Feb 2013 05:00:55 +0000 (16:00 +1100)
Now that we use O_DIRECT for all device IO, BLKFLSBUF is not needed to
ensure we get current data, and it can impose a cost if any flush-out
is needed.  So remove it.

To be safe, add O_DIRECT to one place where it isn't currently used:
when reading a bitmap.

Signed-off-by: NeilBrown <neilb@suse.de>
bitmap.c
super-gpt.c
super-mbr.c
super0.c
super1.c

index 97f33ffaa370805a36b070ccb4f6529be0d28730..028225d525e741eab8b393c67df6f3688f7b5323 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -207,7 +207,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
                return NULL;
        }
        if ((S_IFMT & stb.st_mode) == S_IFBLK) {
-               fd = open(filename, O_RDONLY);
+               fd = open(filename, O_RDONLY|O_DIRECT);
                if (fd < 0) {
                        pr_err("failed to open bitmap file %s: %s\n",
                                filename, strerror(errno));
@@ -225,7 +225,6 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
                } else
                        st->ss->locate_bitmap(st, fd);
 
-               ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
                *stp = st;
        } else {
                fd = open(filename, O_RDONLY|O_DIRECT);
index 6244657d054716ce43cca168a459fcfe2a89705f..8f7d4d93e0585eb2fec48d7d5d879c2f06161875 100644 (file)
@@ -82,8 +82,6 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
        no_read:
index 4218619344cb858b6bd52c39b1ca81ea83627e85..8b175e3185128054ec69e0b0f0a5873b3aa6c7a5 100644 (file)
@@ -86,8 +86,6 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
                if (devname)
@@ -126,8 +124,6 @@ static int store_mbr(struct supertype *st, int fd)
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
                free(old);
index ecb6b38202c26c9db6fbbd0307aba352bc95782a..d54a5d7ff92cf909dbb87fa7beb410c7eb34ec38 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -870,8 +870,6 @@ static int load_super0(struct supertype *st, int fd, char *devname)
 
        offset *= 512;
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        if (lseek64(fd, offset, 0)< 0LL) {
                if (devname)
                        pr_err("Cannot seek to superblock on %s: %s\n",
index 3236a7e28b301f3ef481b50c6180b8473734133e..fe83af5b3d00619b04622e8eb82c19411f2d1d71 100644 (file)
--- a/super1.c
+++ b/super1.c
@@ -1633,9 +1633,6 @@ static int load_super1(struct supertype *st, int fd, char *devname)
                return -EINVAL;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
-
        if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
                if (devname)
                        pr_err("Cannot seek to superblock on %s: %s\n",