From ae21fce625ec6cd134fa4764683f00bc692132cb 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. Change-Id: I821b023d392336f0085a96e821dc22e92dbf23b7 Signed-off-by: Alex Zhuravlev Reviewed-on: https://review.whamcloud.com/36704 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Li Xi Tested-by: Maloo --- 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 c3c62e5..6e14946 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -1146,8 +1146,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 2164421..997c2c5 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1681,9 +1681,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); @@ -1735,7 +1737,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) @@ -1837,9 +1850,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