From patchwork Wed Apr 17 18:57:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Behlendorf X-Patchwork-Id: 2455871 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 26C223FD8C for ; Wed, 17 Apr 2013 18:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966769Ab3DQS5R (ORCPT ); Wed, 17 Apr 2013 14:57:17 -0400 Received: from prdiron-2.llnl.gov ([128.15.143.172]:2756 "EHLO prdiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966517Ab3DQS5Q (ORCPT ); Wed, 17 Apr 2013 14:57:16 -0400 X-Attachments: Received: from eris.llnl.gov (HELO [192.168.1.129]) ([128.115.7.7]) by prdiron-2.llnl.gov with ESMTP; 17 Apr 2013 11:57:06 -0700 Message-ID: <516EF07E.4000909@llnl.gov> Date: Wed, 17 Apr 2013 11:57:02 -0700 From: Brian Behlendorf User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Yehuda Sadeh CC: Sage Weil , Jeff Mitchell , Henry C Chang , Aleksey Leonov , ceph-devel Subject: Re: test osd on zfs References: <516E7D5C.7080309@nazarianin.com> <516ECFB6.8090107@gmail.com> In-Reply-To: Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Here's a patch for the ERANGE error (lightly tested). Sage's patch looks good but only covers one of two code paths for xattrs. With zfs they may either be stored as a system attribute which is usually close to the dnode on disk (zfs set xattr=sa pool/dataset). Or they may be stored in their own object which is how it's implemented on Solaris (zfs set xattr=on pool/dataset). The second method is still the default for compatibility reasons even though it's slower. Sage's patch only covered the SA case. > Well, looking at the code again it's not going to work, as setxattr is > going to fail with ERANGE. Why? We support an arbitrary number of maximum sized xattrs (65536). What am I missing here? Incidentally, does anybody know of an good xattr test suite we could add to our regression tests? Thanks, Brian if (xip) @@ -263,7 +268,10 @@ zpl_xattr_get_sa(struct inode *ip, const char *name, void *value, size_t size) if (!size) return (nv_size); - memcpy(value, nv_value, MIN(size, nv_size)); + if (size < nv_size) + return (-ERANGE); + + memcpy(value, nv_value, size); return (MIN(size, nv_size)); } --- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c index c03764f..9f4d63c 100644 --- a/module/zfs/zpl_xattr.c +++ b/module/zfs/zpl_xattr.c @@ -225,6 +225,11 @@ zpl_xattr_get_dir(struct inode *ip, const char *name, void *value, goto out; } + if (size < i_size_read(xip)) { + error = -ERANGE; + goto out; + } + error = zpl_read_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr); out: