4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details. A copy is
14 * included in the COPYING file that accompanied this code.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Copyright (c) 2012, Intel Corporation.
24 * Use is subject to license terms.
25 * Copyright (c) 2011, 2012 Commissariat a l'energie atomique et aux energies
29 * lustre/mdt/mdt_hsm.c
31 * Lustre Metadata Target (mdt) request handler
33 * Author: Aurelien Degremont <aurelien.degremont@cea.fr>
34 * Author: JC Lafoucriere <jacques-charles.lafoucriere@cea.fr>
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_MDS
42 #include "mdt_internal.h"
45 * fake functions, will be replace by real one with HSM Coordinator patch
48 int mdt_hsm_copytool_send(struct obd_export *exp)
53 static int mdt_hsm_coordinator_update(struct mdt_thread_info *info,
54 struct hsm_progress_kernel *pgs)
59 static int mdt_hsm_agent_register_mask(struct mdt_thread_info *info,
60 struct obd_uuid *uuid,
66 static int mdt_hsm_agent_unregister(struct mdt_thread_info *info,
67 struct obd_uuid *uuid)
73 * Update on-disk HSM attributes.
75 int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj,
78 struct md_object *next = mdt_object_child(obj);
79 struct lu_buf *buf = &info->mti_buf;
80 struct hsm_attrs *attrs;
84 attrs = (struct hsm_attrs *)info->mti_xattr_buf;
85 CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*attrs));
87 /* pack HSM attributes */
88 lustre_hsm2buf(info->mti_xattr_buf, mh);
90 /* update SOM attributes */
92 buf->lb_len = sizeof(*attrs);
93 rc = mo_xattr_set(info->mti_env, next, buf, XATTR_NAME_HSM, 0);
99 * Extract information coming from a copytool and asks coordinator to update
100 * a request status depending on the update content.
102 * Copytools could use this to report failure in their process.
104 * This is HSM_PROGRESS RPC handler.
106 int mdt_hsm_progress(struct mdt_thread_info *info)
108 struct hsm_progress_kernel *hpk;
112 hpk = req_capsule_client_get(info->mti_pill, &RMF_MDS_HSM_PROGRESS);
115 CDEBUG(D_HSM, "Progress on "DFID": len="LPU64" err=%d\n",
116 PFID(&hpk->hpk_fid), hpk->hpk_extent.length, hpk->hpk_errval);
119 CDEBUG(D_HSM, "Copytool progress on "DFID" failed (%d); %s.\n",
120 PFID(&hpk->hpk_fid), hpk->hpk_errval,
121 hpk->hpk_flags & HP_FLAG_RETRY ? "will retry" : "fatal");
123 if (hpk->hpk_flags & HP_FLAG_COMPLETED)
124 CDEBUG(D_HSM, "Finished "DFID" (%d) cancel cookie="LPX64"\n",
125 PFID(&hpk->hpk_fid), hpk->hpk_errval, hpk->hpk_cookie);
127 rc = mdt_hsm_coordinator_update(info, hpk);
132 int mdt_hsm_ct_register(struct mdt_thread_info *info)
134 struct ptlrpc_request *req = mdt_info_req(info);
139 archives = req_capsule_client_get(info->mti_pill, &RMF_MDS_HSM_ARCHIVE);
142 /* XXX: directly include this function here? */
143 rc = mdt_hsm_agent_register_mask(info, &req->rq_export->exp_client_uuid,
149 int mdt_hsm_ct_unregister(struct mdt_thread_info *info)
151 struct ptlrpc_request *req = mdt_info_req(info);
155 /* XXX: directly include this function here? */
156 rc = mdt_hsm_agent_unregister(info, &req->rq_export->exp_client_uuid);