Whamcloud - gitweb
LU-4075 osd: handle getxattr for trusted.version 49/11649/2
authorJohn L. Hammond <john.hammond@intel.com>
Fri, 29 Aug 2014 13:25:36 +0000 (08:25 -0500)
committerAndreas Dilger <andreas.dilger@intel.com>
Sat, 25 Oct 2014 00:04:53 +0000 (00:04 +0000)
In the ldiskfs osd_xattr_get() remove an assertion on the size of the
supplied buffer and add normal handling.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ie4d3b4ab6dd1e8328404d1f8e5b403130b62e64a
Reviewed-on: http://review.whamcloud.com/11649
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/osd-ldiskfs/osd_handler.c

index 65ffaca..cc24aa2 100644 (file)
@@ -2923,9 +2923,15 @@ static int osd_xattr_get(const struct lu_env *env, struct dt_object *dt,
         if (strcmp(name, XATTR_NAME_VERSION) == 0) {
                 /* for version we are just using xattr API but change inode
                  * field instead */
-                LASSERT(buf->lb_len == sizeof(dt_obj_version_t));
-                osd_object_version_get(env, dt, buf->lb_buf);
-                return sizeof(dt_obj_version_t);
+               if (buf->lb_len == 0)
+                       return sizeof(dt_obj_version_t);
+
+               if (buf->lb_len < sizeof(dt_obj_version_t))
+                       return -ERANGE;
+
+               osd_object_version_get(env, dt, buf->lb_buf);
+
+               return sizeof(dt_obj_version_t);
         }
 
        LASSERT(dt_object_exists(dt) && !dt_object_remote(dt));