Skip to content

Commit 9698df1

Browse files
committed
Avoid using BLKFLSBUF.
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 <[email protected]>
1 parent ec1b28f commit 9698df1

File tree

5 files changed

+1
-13
lines changed

5 files changed

+1
-13
lines changed

bitmap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
207207
return NULL;
208208
}
209209
if ((S_IFMT & stb.st_mode) == S_IFBLK) {
210-
fd = open(filename, O_RDONLY);
210+
fd = open(filename, O_RDONLY|O_DIRECT);
211211
if (fd < 0) {
212212
pr_err("failed to open bitmap file %s: %s\n",
213213
filename, strerror(errno));
@@ -225,7 +225,6 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
225225
} else
226226
st->ss->locate_bitmap(st, fd);
227227

228-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
229228
*stp = st;
230229
} else {
231230
fd = open(filename, O_RDONLY|O_DIRECT);

super-gpt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
8282
return 1;
8383
}
8484

85-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
86-
8785
lseek(fd, 0, 0);
8886
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
8987
no_read:

super-mbr.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
8686
return 1;
8787
}
8888

89-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
90-
9189
lseek(fd, 0, 0);
9290
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
9391
if (devname)
@@ -126,8 +124,6 @@ static int store_mbr(struct supertype *st, int fd)
126124
return 1;
127125
}
128126

129-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
130-
131127
lseek(fd, 0, 0);
132128
if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
133129
free(old);

super0.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,6 @@ static int load_super0(struct supertype *st, int fd, char *devname)
870870

871871
offset *= 512;
872872

873-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
874-
875873
if (lseek64(fd, offset, 0)< 0LL) {
876874
if (devname)
877875
pr_err("Cannot seek to superblock on %s: %s\n",

super1.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,9 +1633,6 @@ static int load_super1(struct supertype *st, int fd, char *devname)
16331633
return -EINVAL;
16341634
}
16351635

1636-
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
1637-
1638-
16391636
if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
16401637
if (devname)
16411638
pr_err("Cannot seek to superblock on %s: %s\n",

0 commit comments

Comments
 (0)