MDEV-25734 mbstream breaks page compression on XFS
try harder to punch holes on xfs, don't rely on its heuristics to do the right thing
This commit is contained in:
parent
073a088f31
commit
e9b38f684f
@ -28,6 +28,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
|
|||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE
|
||||||
|
#include <linux/falloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
File fd;
|
File fd;
|
||||||
my_bool init_ibd_done;
|
my_bool init_ibd_done;
|
||||||
@ -160,9 +164,18 @@ static int write_compressed(File fd, uchar *data, size_t len, size_t pagesize)
|
|||||||
if (datasize < n_bytes) {
|
if (datasize < n_bytes) {
|
||||||
/* This punches a "hole" in the file. */
|
/* This punches a "hole" in the file. */
|
||||||
size_t hole_bytes = n_bytes - datasize;
|
size_t hole_bytes = n_bytes - datasize;
|
||||||
if (my_seek(fd, hole_bytes, MY_SEEK_CUR, MYF(MY_WME | MY_NABP))
|
my_off_t off = my_seek(fd, hole_bytes, MY_SEEK_CUR, MYF(MY_WME | MY_NABP));
|
||||||
== MY_FILEPOS_ERROR)
|
if (off == MY_FILEPOS_ERROR)
|
||||||
return 1;
|
return 1;
|
||||||
|
#ifdef HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE
|
||||||
|
/* punch holes harder for filesystems (like XFS) that
|
||||||
|
heuristically decide whether leave a hole after the
|
||||||
|
above or not based on the current access pattern
|
||||||
|
(which is sequential write and not at all typical for
|
||||||
|
what InnoDB will be doing with the file later */
|
||||||
|
fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
|
||||||
|
off - hole_bytes, hole_bytes);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
written += n_bytes;
|
written += n_bytes;
|
||||||
ptr += n_bytes;
|
ptr += n_bytes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user