Whamcloud - gitweb
LU-2378 lma: move HSM & SOM attributes to dedicated xattrs
[fs/lustre-release.git] / lustre / mdt / mdt_hsm.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, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 021110-1307, USA
20  *
21  * GPL HEADER END
22  */
23 /*
24  * Copyright (c) 2012 Intel Corporation
25  * Use is subject to license terms.
26  */
27
28 #define DEBUG_SUBSYSTEM S_MDS
29
30 #include "mdt_internal.h"
31
32 /**
33  * Update on-disk HSM attributes.
34  */
35 int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj,
36                      struct md_hsm *mh)
37 {
38         struct md_object        *next = mdt_object_child(obj);
39         struct lu_buf           *buf = &info->mti_buf;
40         struct hsm_attrs        *attrs;
41         int                      rc;
42         ENTRY;
43
44         attrs = (struct hsm_attrs *)info->mti_xattr_buf;
45         CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*attrs));
46
47         /* pack HSM attributes */
48         lustre_hsm2buf(info->mti_xattr_buf, mh);
49
50         /* update SOM attributes */
51         buf->lb_buf = attrs;
52         buf->lb_len = sizeof(*attrs);
53         rc = mo_xattr_set(info->mti_env, next, buf, XATTR_NAME_HSM, 0);
54
55         RETURN(rc);
56 }