Whamcloud - gitweb
LU-12988 osd: do not use preallocation during mount 04/36704/5
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 14 Nov 2019 15:13:16 +0000 (18:13 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Dec 2019 05:59:09 +0000 (05:59 +0000)
as cold mballoc cache can cause very lengthy search.

Change-Id: I821b023d392336f0085a96e821dc22e92dbf23b7
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36704
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index c3c62e5..6e14946 100644 (file)
@@ -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,
index 2164421..997c2c5 100644 (file)
@@ -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;