Whamcloud - gitweb
3db8073d5416b010dc3a887e0e9a8ae32f3a89c5
[fs/lustre-release.git] / lustre / llite / xattr.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2013, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #include <linux/fs.h>
38 #include <linux/sched.h>
39 #include <linux/mm.h>
40 #include <linux/selinux.h>
41
42 #define DEBUG_SUBSYSTEM S_LLITE
43
44 #include <obd_support.h>
45 #include <lustre_lite.h>
46 #include <lustre_dlm.h>
47 #include <lustre_ver.h>
48 #include <lustre_eacl.h>
49
50 #include "llite_internal.h"
51
52 #define XATTR_USER_T            (1)
53 #define XATTR_TRUSTED_T         (2)
54 #define XATTR_SECURITY_T        (3)
55 #define XATTR_ACL_ACCESS_T      (4)
56 #define XATTR_ACL_DEFAULT_T     (5)
57 #define XATTR_LUSTRE_T          (6)
58 #define XATTR_OTHER_T           (7)
59
60 static
61 int get_xattr_type(const char *name)
62 {
63         if (!strcmp(name, POSIX_ACL_XATTR_ACCESS))
64                 return XATTR_ACL_ACCESS_T;
65
66         if (!strcmp(name, POSIX_ACL_XATTR_DEFAULT))
67                 return XATTR_ACL_DEFAULT_T;
68
69         if (!strncmp(name, XATTR_USER_PREFIX,
70                      sizeof(XATTR_USER_PREFIX) - 1))
71                 return XATTR_USER_T;
72
73         if (!strncmp(name, XATTR_TRUSTED_PREFIX,
74                      sizeof(XATTR_TRUSTED_PREFIX) - 1))
75                 return XATTR_TRUSTED_T;
76
77         if (!strncmp(name, XATTR_SECURITY_PREFIX,
78                      sizeof(XATTR_SECURITY_PREFIX) - 1))
79                 return XATTR_SECURITY_T;
80
81         if (!strncmp(name, XATTR_LUSTRE_PREFIX,
82                      sizeof(XATTR_LUSTRE_PREFIX) - 1))
83                 return XATTR_LUSTRE_T;
84
85         return XATTR_OTHER_T;
86 }
87
88 static
89 int xattr_type_filter(struct ll_sb_info *sbi, int xattr_type)
90 {
91         if ((xattr_type == XATTR_ACL_ACCESS_T ||
92              xattr_type == XATTR_ACL_DEFAULT_T) &&
93            !(sbi->ll_flags & LL_SBI_ACL))
94                 return -EOPNOTSUPP;
95
96         if (xattr_type == XATTR_USER_T && !(sbi->ll_flags & LL_SBI_USER_XATTR))
97                 return -EOPNOTSUPP;
98         if (xattr_type == XATTR_TRUSTED_T && !cfs_capable(CFS_CAP_SYS_ADMIN))
99                 return -EPERM;
100         if (xattr_type == XATTR_OTHER_T)
101                 return -EOPNOTSUPP;
102
103         return 0;
104 }
105
106 static
107 int ll_setxattr_common(struct inode *inode, const char *name,
108                        const void *value, size_t size,
109                        int flags, __u64 valid)
110 {
111         struct ll_sb_info *sbi = ll_i2sbi(inode);
112         struct ptlrpc_request *req = NULL;
113         int xattr_type, rc;
114         struct obd_capa *oc;
115         posix_acl_xattr_header *new_value = NULL;
116         struct rmtacl_ctl_entry *rce = NULL;
117         ext_acl_xattr_header *acl = NULL;
118         const char *pv = value;
119         ENTRY;
120
121         xattr_type = get_xattr_type(name);
122         rc = xattr_type_filter(sbi, xattr_type);
123         if (rc)
124                 RETURN(rc);
125
126         /* b10667: ignore lustre special xattr for now */
127         if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) ||
128             (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0))
129                 RETURN(0);
130
131         /* b15587: ignore security.capability xattr for now */
132         if ((xattr_type == XATTR_SECURITY_T &&
133             strcmp(name, "security.capability") == 0))
134                 RETURN(0);
135
136         /* LU-549:  Disable security.selinux when selinux is disabled */
137         if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
138             strcmp(name, "security.selinux") == 0)
139                 RETURN(-EOPNOTSUPP);
140
141 #ifdef CONFIG_FS_POSIX_ACL
142         if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
143             (xattr_type == XATTR_ACL_ACCESS_T ||
144             xattr_type == XATTR_ACL_DEFAULT_T)) {
145                 rce = rct_search(&sbi->ll_rct, current_pid());
146                 if (rce == NULL ||
147                     (rce->rce_ops != RMT_LSETFACL &&
148                     rce->rce_ops != RMT_RSETFACL))
149                         RETURN(-EOPNOTSUPP);
150
151                 if (rce->rce_ops == RMT_LSETFACL) {
152                         struct eacl_entry *ee;
153
154                         ee = et_search_del(&sbi->ll_et, current_pid(),
155                                            ll_inode2fid(inode), xattr_type);
156                         LASSERT(ee != NULL);
157                         if (valid & OBD_MD_FLXATTR) {
158                                 acl = lustre_acl_xattr_merge2ext(
159                                                 (posix_acl_xattr_header *)value,
160                                                 size, ee->ee_acl);
161                                 if (IS_ERR(acl)) {
162                                         ee_free(ee);
163                                         RETURN(PTR_ERR(acl));
164                                 }
165                                 size =  CFS_ACL_XATTR_SIZE(\
166                                                 le32_to_cpu(acl->a_count), \
167                                                 ext_acl_xattr);
168                                 pv = (const char *)acl;
169                         }
170                         ee_free(ee);
171                 } else if (rce->rce_ops == RMT_RSETFACL) {
172                         int acl_size = lustre_posix_acl_xattr_filter(
173                                                 (posix_acl_xattr_header *)value,
174                                                 size, &new_value);
175                         if (unlikely(acl_size < 0))
176                                 RETURN(acl_size);
177                         size = acl_size;
178
179                         pv = (const char *)new_value;
180                 } else
181                         RETURN(-EOPNOTSUPP);
182
183                 valid |= rce_ops2valid(rce->rce_ops);
184         }
185 #endif
186         oc = ll_mdscapa_get(inode);
187         rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
188                         valid, name, pv, size, 0, flags,
189                         ll_i2suppgid(inode), &req);
190         capa_put(oc);
191 #ifdef CONFIG_FS_POSIX_ACL
192         if (new_value != NULL)
193                 lustre_posix_acl_xattr_free(new_value, size);
194         if (acl != NULL)
195                 lustre_ext_acl_xattr_free(acl);
196 #endif
197         if (rc) {
198                 if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
199                         LCONSOLE_INFO("Disabling user_xattr feature because "
200                                       "it is not supported on the server\n");
201                         sbi->ll_flags &= ~LL_SBI_USER_XATTR;
202                 }
203                 RETURN(rc);
204         }
205
206         ptlrpc_req_finished(req);
207         RETURN(0);
208 }
209
210 int ll_setxattr(struct dentry *dentry, const char *name,
211                 const void *value, size_t size, int flags)
212 {
213         struct inode *inode = dentry->d_inode;
214
215         LASSERT(inode);
216         LASSERT(name);
217
218         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
219                PFID(ll_inode2fid(inode)), inode, name);
220
221         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1);
222
223         if ((strncmp(name, XATTR_TRUSTED_PREFIX,
224                      sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0 &&
225              strcmp(name + sizeof(XATTR_TRUSTED_PREFIX) - 1, "lov") == 0) ||
226             (strncmp(name, XATTR_LUSTRE_PREFIX,
227                      sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 &&
228              strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) {
229                 struct lov_user_md *lump = (struct lov_user_md *)value;
230                 int rc = 0;
231
232                 /* Attributes that are saved via getxattr will always have
233                  * the stripe_offset as 0.  Instead, the MDS should be
234                  * allowed to pick the starting OST index.   b=17846 */
235                 if (lump != NULL && lump->lmm_stripe_offset == 0)
236                         lump->lmm_stripe_offset = -1;
237
238                 if (lump != NULL && S_ISREG(inode->i_mode)) {
239                         struct file     f;
240                         __u64           it_flags = FMODE_WRITE;
241                         int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ?
242                                 sizeof(*lump) : sizeof(struct lov_user_md_v3);
243
244                         f.f_dentry = dentry;
245                         rc = ll_lov_setstripe_ea_info(inode, &f, it_flags, lump,
246                                                       lum_size);
247                         /* b10667: rc always be 0 here for now */
248                         rc = 0;
249                 } else if (S_ISDIR(inode->i_mode)) {
250                         rc = ll_dir_setstripe(inode, lump, 0);
251                 }
252
253                 return rc;
254
255         } else if (strcmp(name, XATTR_NAME_LMA) == 0 ||
256                    strcmp(name, XATTR_NAME_LINK) == 0)
257                 return 0;
258
259         return ll_setxattr_common(inode, name, value, size, flags,
260                                   OBD_MD_FLXATTR);
261 }
262
263 int ll_removexattr(struct dentry *dentry, const char *name)
264 {
265         struct inode *inode = dentry->d_inode;
266
267         LASSERT(inode);
268         LASSERT(name);
269
270         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
271                PFID(ll_inode2fid(inode)), inode, name);
272
273         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);
274         return ll_setxattr_common(inode, name, NULL, 0, 0,
275                                   OBD_MD_FLXATTRRM);
276 }
277
278 static
279 int ll_getxattr_common(struct inode *inode, const char *name,
280                        void *buffer, size_t size, __u64 valid)
281 {
282         struct ll_sb_info *sbi = ll_i2sbi(inode);
283         struct ptlrpc_request *req = NULL;
284         struct mdt_body *body;
285         int xattr_type, rc;
286         void *xdata;
287         struct obd_capa *oc;
288         struct rmtacl_ctl_entry *rce = NULL;
289         struct ll_inode_info *lli = ll_i2info(inode);
290         ENTRY;
291
292         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
293                PFID(ll_inode2fid(inode)), inode);
294
295         /* listxattr have slightly different behavior from of ext3:
296          * without 'user_xattr' ext3 will list all xattr names but
297          * filtered out "^user..*"; we list them all for simplicity.
298          */
299         if (!name) {
300                 xattr_type = XATTR_OTHER_T;
301                 goto do_getxattr;
302         }
303
304         xattr_type = get_xattr_type(name);
305         rc = xattr_type_filter(sbi, xattr_type);
306         if (rc)
307                 RETURN(rc);
308
309         /* b15587: ignore security.capability xattr for now */
310         if ((xattr_type == XATTR_SECURITY_T &&
311             strcmp(name, "security.capability") == 0))
312                 RETURN(-ENODATA);
313
314         /* LU-549:  Disable security.selinux when selinux is disabled */
315         if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() &&
316             strcmp(name, "security.selinux") == 0)
317                 RETURN(-EOPNOTSUPP);
318
319 #ifdef CONFIG_FS_POSIX_ACL
320         if (sbi->ll_flags & LL_SBI_RMT_CLIENT &&
321             (xattr_type == XATTR_ACL_ACCESS_T ||
322             xattr_type == XATTR_ACL_DEFAULT_T)) {
323                 rce = rct_search(&sbi->ll_rct, current_pid());
324                 if (rce == NULL ||
325                     (rce->rce_ops != RMT_LSETFACL &&
326                     rce->rce_ops != RMT_LGETFACL &&
327                     rce->rce_ops != RMT_RSETFACL &&
328                     rce->rce_ops != RMT_RGETFACL))
329                         RETURN(-EOPNOTSUPP);
330         }
331
332         /* posix acl is under protection of LOOKUP lock. when calling to this,
333          * we just have path resolution to the target inode, so we have great
334          * chance that cached ACL is uptodate.
335          */
336         if (xattr_type == XATTR_ACL_ACCESS_T &&
337             !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) {
338
339                 struct posix_acl *acl;
340
341                 spin_lock(&lli->lli_lock);
342                 acl = posix_acl_dup(lli->lli_posix_acl);
343                 spin_unlock(&lli->lli_lock);
344
345                 if (!acl)
346                         RETURN(-ENODATA);
347
348                 rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
349                 posix_acl_release(acl);
350                 RETURN(rc);
351         }
352         if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode))
353                 RETURN(-ENODATA);
354 #endif
355
356 do_getxattr:
357         if (sbi->ll_xattr_cache_enabled && xattr_type != XATTR_ACL_ACCESS_T) {
358                 rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
359                 if (rc == -EAGAIN)
360                         goto getxattr_nocache;
361                 if (rc < 0)
362                         GOTO(out_xattr, rc);
363
364                 /* Add "system.posix_acl_access" to the list */
365                 if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
366                         if (size == 0) {
367                                 rc += sizeof(XATTR_NAME_ACL_ACCESS);
368                         } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
369                                 memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
370                                        sizeof(XATTR_NAME_ACL_ACCESS));
371                                 rc += sizeof(XATTR_NAME_ACL_ACCESS);
372                         } else {
373                                 GOTO(out_xattr, rc = -ERANGE);
374                         }
375                 }
376         } else {
377 getxattr_nocache:
378                 oc = ll_mdscapa_get(inode);
379                 rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
380                                 valid | (rce ? rce_ops2valid(rce->rce_ops) : 0),
381                                 name, NULL, 0, size, 0, &req);
382                 capa_put(oc);
383
384                 if (rc < 0)
385                         GOTO(out_xattr, rc);
386
387                 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
388                 LASSERT(body);
389
390                 /* only detect the xattr size */
391                 if (size == 0)
392                         GOTO(out, rc = body->eadatasize);
393
394                 if (size < body->eadatasize) {
395                         CERROR("server bug: replied size %u > %u\n",
396                                 body->eadatasize, (int)size);
397                         GOTO(out, rc = -ERANGE);
398                 }
399
400                 if (body->eadatasize == 0)
401                         GOTO(out, rc = -ENODATA);
402
403                 /* do not need swab xattr data */
404                 xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
405                                                         body->eadatasize);
406                 if (!xdata)
407                         GOTO(out, rc = -EFAULT);
408
409                 memcpy(buffer, xdata, body->eadatasize);
410                 rc = body->eadatasize;
411         }
412
413 #ifdef CONFIG_FS_POSIX_ACL
414         if (rce != NULL && rce->rce_ops == RMT_LSETFACL) {
415                 ext_acl_xattr_header *acl;
416
417                 acl = lustre_posix_acl_xattr_2ext(buffer, rc);
418                 if (IS_ERR(acl))
419                         GOTO(out, rc = PTR_ERR(acl));
420
421                 rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
422                             xattr_type, acl);
423                 if (unlikely(rc < 0)) {
424                         lustre_ext_acl_xattr_free(acl);
425                         GOTO(out, rc);
426                 }
427         }
428 #endif
429         EXIT;
430
431 out_xattr:
432         if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
433                 LCONSOLE_INFO("%s: disabling user_xattr feature because "
434                                 "it is not supported on the server: rc = %d\n",
435                                 ll_get_fsname(inode->i_sb, NULL, 0), rc);
436                 sbi->ll_flags &= ~LL_SBI_USER_XATTR;
437         }
438 out:
439         ptlrpc_req_finished(req);
440         return rc;
441 }
442
443 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
444                     void *buffer, size_t size)
445 {
446         struct inode *inode = dentry->d_inode;
447
448         LASSERT(inode);
449         LASSERT(name);
450
451         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), xattr %s\n",
452                PFID(ll_inode2fid(inode)), inode, name);
453
454         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_GETXATTR, 1);
455
456         if ((strncmp(name, XATTR_TRUSTED_PREFIX,
457                      sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0 &&
458              strcmp(name + sizeof(XATTR_TRUSTED_PREFIX) - 1, "lov") == 0) ||
459             (strncmp(name, XATTR_LUSTRE_PREFIX,
460                      sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 &&
461              strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) {
462                 struct lov_stripe_md *lsm;
463                 struct lov_user_md *lump;
464                 struct lov_mds_md *lmm = NULL;
465                 struct ptlrpc_request *request = NULL;
466                 int rc = 0, lmmsize = 0;
467
468                 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
469                         return -ENODATA;
470
471                 if (size == 0 && S_ISDIR(inode->i_mode)) {
472                         /* XXX directory EA is fix for now, optimize to save
473                          * RPC transfer */
474                         GOTO(out, rc = sizeof(struct lov_user_md));
475                 }
476
477                 lsm = ccc_inode_lsm_get(inode);
478                 if (lsm == NULL) {
479                         if (S_ISDIR(inode->i_mode)) {
480                                 rc = ll_dir_getstripe(inode, &lmm,
481                                                       &lmmsize, &request);
482                         } else {
483                                 rc = -ENODATA;
484                         }
485                 } else {
486                         /* LSM is present already after lookup/getattr call.
487                          * we need to grab layout lock once it is implemented */
488                         rc = obd_packmd(ll_i2dtexp(inode), &lmm, lsm);
489                         lmmsize = rc;
490                 }
491                 ccc_inode_lsm_put(inode, lsm);
492
493                 if (rc < 0)
494                        GOTO(out, rc);
495
496                 if (size == 0) {
497                         /* used to call ll_get_max_mdsize() forward to get
498                          * the maximum buffer size, while some apps (such as
499                          * rsync 3.0.x) care much about the exact xattr value
500                          * size */
501                         rc = lmmsize;
502                         GOTO(out, rc);
503                 }
504
505                 if (size < lmmsize) {
506                         CERROR("server bug: replied size %d > %d for %s (%s)\n",
507                                lmmsize, (int)size, dentry->d_name.name, name);
508                         GOTO(out, rc = -ERANGE);
509                 }
510
511                 lump = (struct lov_user_md *)buffer;
512                 memcpy(lump, lmm, lmmsize);
513                 /* do not return layout gen for getxattr otherwise it would
514                  * confuse tar --xattr by recognizing layout gen as stripe
515                  * offset when the file is restored. See LU-2809. */
516                 lump->lmm_layout_gen = 0;
517
518                 rc = lmmsize;
519 out:
520                 if (request)
521                         ptlrpc_req_finished(request);
522                 else if (lmm)
523                         obd_free_diskmd(ll_i2dtexp(inode), &lmm);
524                 return(rc);
525         }
526
527         return ll_getxattr_common(inode, name, buffer, size, OBD_MD_FLXATTR);
528 }
529
530 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
531 {
532         struct inode *inode = dentry->d_inode;
533         int rc = 0, rc2 = 0;
534         struct lov_mds_md *lmm = NULL;
535         struct ptlrpc_request *request = NULL;
536         int lmmsize;
537
538         LASSERT(inode);
539
540         CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
541                PFID(ll_inode2fid(inode)), inode);
542
543         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_LISTXATTR, 1);
544
545         rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);
546         if (rc < 0)
547                 GOTO(out, rc);
548
549         if (buffer != NULL) {
550                 struct ll_sb_info *sbi = ll_i2sbi(inode);
551                 char *xattr_name = buffer;
552                 int xlen, rem = rc;
553
554                 while (rem > 0) {
555                         xlen = strnlen(xattr_name, rem - 1) + 1;
556                         rem -= xlen;
557                         if (xattr_type_filter(sbi,
558                                         get_xattr_type(xattr_name)) == 0) {
559                                 /* skip OK xattr type
560                                  * leave it in buffer
561                                  */
562                                 xattr_name += xlen;
563                                 continue;
564                         }
565                         /* move up remaining xattrs in buffer
566                          * removing the xattr that is not OK
567                          */
568                         memmove(xattr_name, xattr_name + xlen, rem);
569                         rc -= xlen;
570                 }
571         }
572         if (S_ISREG(inode->i_mode)) {
573                 if (!ll_i2info(inode)->lli_has_smd)
574                         rc2 = -1;
575         } else if (S_ISDIR(inode->i_mode)) {
576                 rc2 = ll_dir_getstripe(inode, &lmm, &lmmsize, &request);
577         }
578
579         if (rc2 < 0) {
580                 GOTO(out, rc2 = 0);
581         } else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) {
582                 const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1;
583                 const size_t name_len   = sizeof("lov") - 1;
584                 const size_t total_len  = prefix_len + name_len + 1;
585
586                 if (((rc + total_len) > size) && (buffer != NULL)) {
587                         ptlrpc_req_finished(request);
588                         return -ERANGE;
589                 }
590
591                 if (buffer != NULL) {
592                         buffer += rc;
593                         memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len);
594                         memcpy(buffer + prefix_len, "lov", name_len);
595                         buffer[prefix_len + name_len] = '\0';
596                 }
597                 rc2 = total_len;
598         }
599 out:
600         ptlrpc_req_finished(request);
601         rc = rc + rc2;
602
603         return rc;
604 }