From 2331cd1fa178b348d8aa048abbb5160ac9353461 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 14 Nov 2019 18:13:16 +0300 Subject: [PATCH] LU-12988 osd: do not use preallocation during mount as cold mballoc cache can cause very lengthy search. Lustre-commit: ae21fce625ec6cd134fa4764683f00bc692132cb Lustre-change: https://review.whamcloud.com/36704 Change-Id: I821b023d392336f0085a96e821dc22e92dbf23b7 Signed-off-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Li Xi Reviewed-on: https://review.whamcloud.com/37155 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_internal.h | 2 -- lustre/osd-ldiskfs/osd_io.c | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 30be058..d6285e4 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -1103,8 +1103,6 @@ int osd_calc_bkmap_credits(struct super_block *sb, struct inode *inode, const int blocks); int osd_ldiskfs_read(struct inode *inode, void *buf, int size, loff_t *offs); -int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize, - int write_NUL, loff_t *offs, handle_t *handle); static inline struct dentry *osd_child_dentry_by_inode(const struct lu_env *env, diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 34277a2..a8f69bc 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -2034,9 +2034,11 @@ static int osd_ldiskfs_writelink(struct inode *inode, char *buffer, int buflen) return 0; } -int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize, - int write_NUL, loff_t *offs, handle_t *handle) +static int osd_ldiskfs_write_record(struct dt_object *dt, void *buf, + int bufsize, int write_NUL, loff_t *offs, + handle_t *handle) { + struct inode *inode = osd_dt_obj(dt)->oo_inode; struct buffer_head *bh = NULL; loff_t offset = *offs; loff_t new_size = i_size_read(inode); @@ -2088,7 +2090,18 @@ int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize, offset, block, bufsize, *offs); if (IS_ERR_OR_NULL(bh)) { - bh = __ldiskfs_bread(handle, inode, block, 1); + struct osd_device *osd = osd_obj2dev(osd_dt_obj(dt)); + int flags = LDISKFS_GET_BLOCKS_CREATE; + + /* while the file system is being mounted, avoid + * preallocation otherwise mount can take a long + * time as mballoc cache is cold. + * XXX: this is a workaround until we have a proper + * fix in mballoc + * XXX: works with extent-based files only */ + if (!osd->od_cl_seq) + flags |= LDISKFS_GET_BLOCKS_NO_NORMALIZE; + bh = __ldiskfs_bread(handle, inode, block, flags); create = true; } else { if (sync) @@ -2190,9 +2203,8 @@ static ssize_t osd_write(const struct lu_env *env, struct dt_object *dt, if (is_link && (buf->lb_len < sizeof(LDISKFS_I(inode)->i_data))) result = osd_ldiskfs_writelink(inode, buf->lb_buf, buf->lb_len); else - result = osd_ldiskfs_write_record(inode, buf->lb_buf, - buf->lb_len, is_link, pos, - oh->ot_handle); + result = osd_ldiskfs_write_record(dt, buf->lb_buf, buf->lb_len, + is_link, pos, oh->ot_handle); if (result == 0) result = buf->lb_len; -- 1.8.3.1