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 <neilb@suse.de>
This commit is contained in:
parent
ec1b28fdc0
commit
9698df15d9
3
bitmap.c
3
bitmap.c
|
@ -207,7 +207,7 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((S_IFMT & stb.st_mode) == S_IFBLK) {
|
if ((S_IFMT & stb.st_mode) == S_IFBLK) {
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY|O_DIRECT);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
pr_err("failed to open bitmap file %s: %s\n",
|
pr_err("failed to open bitmap file %s: %s\n",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
|
@ -225,7 +225,6 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype **st
|
||||||
} else
|
} else
|
||||||
st->ss->locate_bitmap(st, fd);
|
st->ss->locate_bitmap(st, fd);
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
*stp = st;
|
*stp = st;
|
||||||
} else {
|
} else {
|
||||||
fd = open(filename, O_RDONLY|O_DIRECT);
|
fd = open(filename, O_RDONLY|O_DIRECT);
|
||||||
|
|
|
@ -82,8 +82,6 @@ static int load_gpt(struct supertype *st, int fd, char *devname)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
|
|
||||||
lseek(fd, 0, 0);
|
lseek(fd, 0, 0);
|
||||||
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
|
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
|
||||||
no_read:
|
no_read:
|
||||||
|
|
|
@ -86,8 +86,6 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
|
|
||||||
lseek(fd, 0, 0);
|
lseek(fd, 0, 0);
|
||||||
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
|
if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
|
||||||
if (devname)
|
if (devname)
|
||||||
|
@ -126,8 +124,6 @@ static int store_mbr(struct supertype *st, int fd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
|
|
||||||
lseek(fd, 0, 0);
|
lseek(fd, 0, 0);
|
||||||
if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
|
if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
|
||||||
free(old);
|
free(old);
|
||||||
|
|
2
super0.c
2
super0.c
|
@ -870,8 +870,6 @@ static int load_super0(struct supertype *st, int fd, char *devname)
|
||||||
|
|
||||||
offset *= 512;
|
offset *= 512;
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
|
|
||||||
if (lseek64(fd, offset, 0)< 0LL) {
|
if (lseek64(fd, offset, 0)< 0LL) {
|
||||||
if (devname)
|
if (devname)
|
||||||
pr_err("Cannot seek to superblock on %s: %s\n",
|
pr_err("Cannot seek to superblock on %s: %s\n",
|
||||||
|
|
3
super1.c
3
super1.c
|
@ -1633,9 +1633,6 @@ static int load_super1(struct supertype *st, int fd, char *devname)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
|
|
||||||
|
|
||||||
|
|
||||||
if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
|
if (lseek64(fd, sb_offset << 9, 0)< 0LL) {
|
||||||
if (devname)
|
if (devname)
|
||||||
pr_err("Cannot seek to superblock on %s: %s\n",
|
pr_err("Cannot seek to superblock on %s: %s\n",
|
||||||
|
|
Loading…
Reference in New Issue