Whamcloud - gitweb
LU-5770 osd: find bufsize in declare_xattr_set 12/12412/11
authorAlexander Zarochentsev <alexander.zarochentsev@seagate.com>
Fri, 24 Oct 2014 03:42:27 +0000 (07:42 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 30 Oct 2015 16:42:45 +0000 (16:42 +0000)
mdd_link/mdd_unlink need to know LINKEA buffer size before
transaction start for correct estimation of tx credits.
In case if xattr size not known, make a call to osd_xattr_set()
to find correct buffer size.

Xyratex-bug-id: MRP-2093
Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@seagate.com>
Change-Id: I890e8182bd2d191a0322d25f0684f2a220873546
Reviewed-on: http://review.whamcloud.com/12412
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index aebd82f..a2e8f51 100644 (file)
@@ -3086,9 +3086,29 @@ static int osd_declare_xattr_set(const struct lu_env *env,
        } else {
 upgrade:
                credits = osd_dto_credits_noquota[DTO_XATTR_SET];
-               if (buf && buf->lb_len > sb->s_blocksize) {
-                       credits *= (buf->lb_len + sb->s_blocksize - 1) >>
-                                       sb->s_blocksize_bits;
+
+               if (buf != NULL) {
+                       ssize_t buflen;
+
+                       if (buf->lb_buf == NULL && dt_object_exists(dt)) {
+                               /* learn xattr size from osd_xattr_get if
+                                  attribute has not been read yet */
+                               buflen = __osd_xattr_get(
+                                   osd_dt_obj(dt)->oo_inode,
+                                   &osd_oti_get(env)->oti_obj_dentry,
+                                   name, NULL, 0);
+                               if (buflen < 0)
+                                       buflen = 0;
+                       } else {
+                               buflen = buf->lb_len;
+                       }
+
+                       if (buflen > sb->s_blocksize) {
+                               credits += osd_calc_bkmap_credits(
+                                   sb, NULL, 0, -1,
+                                   (buflen + sb->s_blocksize - 1) >>
+                                   sb->s_blocksize_bits);
+                       }
                }
                /*
                 * xattr set may involve inode quota change, reserve credits for
index 7ef1032..b182ad9 100644 (file)
@@ -936,6 +936,10 @@ static inline void osd_ipd_put(const struct lu_env *env,
         bag->ic_descr->id_ops->id_ipd_free(ipd);
 }
 
+int osd_calc_bkmap_credits(struct super_block *sb, struct inode *inode,
+                          const loff_t size, const loff_t pos,
+                          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);
index 83c72ff..2373646 100644 (file)
@@ -1488,11 +1488,9 @@ static inline int osd_extents_enabled(struct super_block *sb,
        return 0;
 }
 
-static inline int osd_calc_bkmap_credits(struct super_block *sb,
-                                        struct inode *inode,
-                                        const loff_t size,
-                                        const loff_t pos,
-                                        const int blocks)
+int osd_calc_bkmap_credits(struct super_block *sb, struct inode *inode,
+                          const loff_t size, const loff_t pos,
+                          const int blocks)
 {
        int credits, bits, bs, i;