Whamcloud - gitweb
LU-6401 headers: Create a header for obdo related functions
[fs/lustre-release.git] / lustre / target / out_handler.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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2013, 2015, Intel Corporation.
24  *
25  * lustre/target/out_handler.c
26  *
27  * Object update handler between targets.
28  *
29  * Author: di.wang <di.wang@intel.com>
30  */
31
32 #define DEBUG_SUBSYSTEM S_CLASS
33
34 #include <llog_swab.h>
35 #include <lustre_obdo.h>
36 #include <lustre_swab.h>
37 #include <lustre_update.h>
38 #include <md_object.h>
39 #include <obd_class.h>
40 #include "tgt_internal.h"
41
42 static void out_reconstruct(const struct lu_env *env, struct dt_device *dt,
43                             struct dt_object *obj,
44                             struct object_update_reply *reply,
45                             int index)
46 {
47         CDEBUG(D_INFO, "%s: fork reply reply %p index %d: rc = %d\n",
48                dt_obd_name(dt), reply, index, 0);
49
50         object_update_result_insert(reply, NULL, 0, index, 0);
51         return;
52 }
53
54 typedef void (*out_reconstruct_t)(const struct lu_env *env,
55                                   struct dt_device *dt,
56                                   struct dt_object *obj,
57                                   struct object_update_reply *reply,
58                                   int index);
59
60 static inline int out_check_resent(const struct lu_env *env,
61                                    struct dt_device *dt,
62                                    struct dt_object *obj,
63                                    struct ptlrpc_request *req,
64                                    out_reconstruct_t reconstruct,
65                                    struct object_update_reply *reply,
66                                    int index)
67 {
68         if (likely(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT)))
69                 return 0;
70
71         if (req_xid_is_last(req)) {
72                 struct lsd_client_data *lcd;
73
74                 /* XXX this does not support mulitple transactions yet, i.e.
75                  * only 1 update RPC each time betwee MDTs */
76                 lcd = req->rq_export->exp_target_data.ted_lcd;
77
78                 req->rq_transno = lcd->lcd_last_transno;
79                 req->rq_status = lcd->lcd_last_result;
80                 if (req->rq_status != 0)
81                         req->rq_transno = 0;
82                 lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
83                 lustre_msg_set_status(req->rq_repmsg, req->rq_status);
84
85                 DEBUG_REQ(D_RPCTRACE, req, "restoring transno "LPD64"status %d",
86                           req->rq_transno, req->rq_status);
87
88                 reconstruct(env, dt, obj, reply, index);
89                 return 1;
90         }
91         DEBUG_REQ(D_HA, req, "no reply for RESENT req (have "LPD64")",
92                  req->rq_export->exp_target_data.ted_lcd->lcd_last_xid);
93         return 0;
94 }
95
96 static int out_create(struct tgt_session_info *tsi)
97 {
98         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
99         struct object_update    *update = tti->tti_u.update.tti_update;
100         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
101         struct dt_object_format *dof = &tti->tti_u.update.tti_update_dof;
102         struct obdo             *lobdo = &tti->tti_u.update.tti_obdo;
103         struct lu_attr          *attr = &tti->tti_attr;
104         struct lu_fid           *fid = NULL;
105         struct obdo             *wobdo;
106         size_t                  size;
107         int                     rc;
108
109         ENTRY;
110
111         wobdo = object_update_param_get(update, 0, &size);
112         if (IS_ERR(wobdo) || size != sizeof(*wobdo)) {
113                 CERROR("%s: obdo is NULL, invalid RPC: rc = %ld\n",
114                        tgt_name(tsi->tsi_tgt), PTR_ERR(wobdo));
115                 RETURN(PTR_ERR(wobdo));
116         }
117
118         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
119                 lustre_swab_obdo(wobdo);
120         lustre_get_wire_obdo(NULL, lobdo, wobdo);
121         la_from_obdo(attr, lobdo, lobdo->o_valid);
122
123         dof->dof_type = dt_mode_to_dft(attr->la_mode);
124         if (update->ou_params_count > 1) {
125                 fid = object_update_param_get(update, 1, &size);
126                 if (IS_ERR(fid) || size != sizeof(*fid)) {
127                         CERROR("%s: invalid fid: rc = %ld\n",
128                                tgt_name(tsi->tsi_tgt), PTR_ERR(fid));
129                         RETURN(PTR_ERR(fid));
130                 }
131                 if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
132                         lustre_swab_lu_fid(fid);
133                 if (!fid_is_sane(fid)) {
134                         CERROR("%s: invalid fid "DFID": rc = %d\n",
135                                tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO);
136                         RETURN(-EPROTO);
137                 }
138         }
139
140         if (lu_object_exists(&obj->do_lu))
141                 RETURN(-EEXIST);
142
143         rc = out_tx_create(tsi->tsi_env, obj, attr, fid, dof,
144                            &tti->tti_tea, tti->tti_tea.ta_handle,
145                            tti->tti_u.update.tti_update_reply,
146                            tti->tti_u.update.tti_update_reply_index);
147
148         RETURN(rc);
149 }
150
151 static int out_attr_set(struct tgt_session_info *tsi)
152 {
153         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
154         struct object_update    *update = tti->tti_u.update.tti_update;
155         struct lu_attr          *attr = &tti->tti_attr;
156         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
157         struct obdo             *lobdo = &tti->tti_u.update.tti_obdo;
158         struct obdo             *wobdo;
159         size_t                   size;
160         int                      rc;
161
162         ENTRY;
163
164         wobdo = object_update_param_get(update, 0, &size);
165         if (IS_ERR(wobdo) || size != sizeof(*wobdo)) {
166                 CERROR("%s: empty obdo in the update: rc = %ld\n",
167                        tgt_name(tsi->tsi_tgt), PTR_ERR(wobdo));
168                 RETURN(PTR_ERR(wobdo));
169         }
170
171         attr->la_valid = 0;
172         attr->la_valid = 0;
173
174         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
175                 lustre_swab_obdo(wobdo);
176         lustre_get_wire_obdo(NULL, lobdo, wobdo);
177         la_from_obdo(attr, lobdo, lobdo->o_valid);
178
179         rc = out_tx_attr_set(tsi->tsi_env, obj, attr, &tti->tti_tea,
180                              tti->tti_tea.ta_handle,
181                              tti->tti_u.update.tti_update_reply,
182                              tti->tti_u.update.tti_update_reply_index);
183
184         RETURN(rc);
185 }
186
187 static int out_attr_get(struct tgt_session_info *tsi)
188 {
189         const struct lu_env     *env = tsi->tsi_env;
190         struct tgt_thread_info  *tti = tgt_th_info(env);
191         struct object_update    *update = tti->tti_u.update.tti_update;
192         struct obdo             *obdo = &tti->tti_u.update.tti_obdo;
193         struct lu_attr          *la = &tti->tti_attr;
194         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
195         int                     idx = tti->tti_u.update.tti_update_reply_index;
196         int                     rc;
197
198         ENTRY;
199
200         if (unlikely(update->ou_result_size < sizeof(*obdo)))
201                 return -EPROTO;
202
203         if (!lu_object_exists(&obj->do_lu)) {
204                 /* Usually, this will be called when the master MDT try
205                  * to init a remote object(see osp_object_init), so if
206                  * the object does not exist on slave, we need set BANSHEE flag,
207                  * so the object can be removed from the cache immediately */
208                 set_bit(LU_OBJECT_HEARD_BANSHEE,
209                         &obj->do_lu.lo_header->loh_flags);
210                 RETURN(-ENOENT);
211         }
212
213         dt_read_lock(env, obj, MOR_TGT_CHILD);
214         rc = dt_attr_get(env, obj, la);
215         if (rc)
216                 GOTO(out_unlock, rc);
217
218         obdo->o_valid = 0;
219         obdo_from_la(obdo, la, la->la_valid);
220         lustre_set_wire_obdo(NULL, obdo, obdo);
221
222 out_unlock:
223         dt_read_unlock(env, obj);
224
225         CDEBUG(D_INFO, "%s: insert attr get reply %p index %d: rc = %d\n",
226                tgt_name(tsi->tsi_tgt), tti->tti_u.update.tti_update_reply,
227                0, rc);
228
229         object_update_result_insert(tti->tti_u.update.tti_update_reply, obdo,
230                                     sizeof(*obdo), idx, rc);
231
232         RETURN(rc);
233 }
234
235 static int out_xattr_get(struct tgt_session_info *tsi)
236 {
237         const struct lu_env        *env = tsi->tsi_env;
238         struct tgt_thread_info     *tti = tgt_th_info(env);
239         struct object_update       *update = tti->tti_u.update.tti_update;
240         struct lu_buf              *lbuf = &tti->tti_buf;
241         struct object_update_reply *reply = tti->tti_u.update.tti_update_reply;
242         struct dt_object           *obj = tti->tti_u.update.tti_dt_object;
243         char                       *name;
244         struct object_update_result *update_result;
245         int                     idx = tti->tti_u.update.tti_update_reply_index;
246         int                        rc;
247
248         ENTRY;
249
250         if (!lu_object_exists(&obj->do_lu)) {
251                 set_bit(LU_OBJECT_HEARD_BANSHEE,
252                         &obj->do_lu.lo_header->loh_flags);
253                 RETURN(-ENOENT);
254         }
255
256         name = object_update_param_get(update, 0, NULL);
257         if (IS_ERR(name)) {
258                 CERROR("%s: empty name for xattr get: rc = %ld\n",
259                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
260                 RETURN(PTR_ERR(name));
261         }
262
263         update_result = object_update_result_get(reply, 0, NULL);
264         if (update_result == NULL) {
265                 CERROR("%s: empty name for xattr get: rc = %d\n",
266                        tgt_name(tsi->tsi_tgt), -EPROTO);
267                 RETURN(-EPROTO);
268         }
269
270         lbuf->lb_len = (int)tti->tti_u.update.tti_update->ou_result_size;
271         lbuf->lb_buf = update_result->our_data;
272         if (lbuf->lb_len == 0)
273                 lbuf->lb_buf = 0;
274         dt_read_lock(env, obj, MOR_TGT_CHILD);
275         rc = dt_xattr_get(env, obj, lbuf, name);
276         dt_read_unlock(env, obj);
277         if (rc < 0)
278                 lbuf->lb_len = 0;
279         CDEBUG(D_INFO, "%s: "DFID" get xattr %s len %d\n",
280                tgt_name(tsi->tsi_tgt), PFID(lu_object_fid(&obj->do_lu)),
281                name, (int)lbuf->lb_len);
282
283         GOTO(out, rc);
284
285 out:
286         object_update_result_insert(reply, lbuf->lb_buf, lbuf->lb_len, idx, rc);
287         RETURN(0);
288 }
289
290 static int out_index_lookup(struct tgt_session_info *tsi)
291 {
292         const struct lu_env     *env = tsi->tsi_env;
293         struct tgt_thread_info  *tti = tgt_th_info(env);
294         struct object_update    *update = tti->tti_u.update.tti_update;
295         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
296         char                    *name;
297         int                      rc;
298
299         ENTRY;
300
301         if (unlikely(update->ou_result_size < sizeof(tti->tti_fid1)))
302                 return -EPROTO;
303
304         if (!lu_object_exists(&obj->do_lu))
305                 RETURN(-ENOENT);
306
307         name = object_update_param_get(update, 0, NULL);
308         if (IS_ERR(name)) {
309                 CERROR("%s: empty name for lookup: rc = %ld\n",
310                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
311                 RETURN(PTR_ERR(name));
312         }
313
314         dt_read_lock(env, obj, MOR_TGT_CHILD);
315         if (!dt_try_as_dir(env, obj))
316                 GOTO(out_unlock, rc = -ENOTDIR);
317
318         rc = dt_lookup(env, obj, (struct dt_rec *)&tti->tti_fid1,
319                        (struct dt_key *)name);
320
321         if (rc < 0)
322                 GOTO(out_unlock, rc);
323
324         if (rc == 0)
325                 rc += 1;
326
327 out_unlock:
328         dt_read_unlock(env, obj);
329
330         CDEBUG(D_INFO, "lookup "DFID" %s get "DFID" rc %d\n",
331                PFID(lu_object_fid(&obj->do_lu)), name,
332                PFID(&tti->tti_fid1), rc);
333
334         CDEBUG(D_INFO, "%s: insert lookup reply %p index %d: rc = %d\n",
335                tgt_name(tsi->tsi_tgt), tti->tti_u.update.tti_update_reply,
336                0, rc);
337
338         object_update_result_insert(tti->tti_u.update.tti_update_reply,
339                             &tti->tti_fid1, sizeof(tti->tti_fid1),
340                             tti->tti_u.update.tti_update_reply_index, rc);
341         RETURN(rc);
342 }
343
344 static int out_xattr_set(struct tgt_session_info *tsi)
345 {
346         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
347         struct object_update    *update = tti->tti_u.update.tti_update;
348         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
349         struct lu_buf           *lbuf = &tti->tti_buf;
350         char                    *name;
351         char                    *buf;
352         __u32                   *tmp;
353         size_t                   buf_len = 0;
354         int                      flag;
355         size_t                   size = 0;
356         int                      rc;
357         ENTRY;
358
359         name = object_update_param_get(update, 0, NULL);
360         if (IS_ERR(name)) {
361                 CERROR("%s: empty name for xattr set: rc = %ld\n",
362                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
363                 RETURN(PTR_ERR(name));
364         }
365
366         /* If buffer == NULL (-ENODATA), then it might mean delete xattr */
367         buf = object_update_param_get(update, 1, &buf_len);
368         if (IS_ERR(buf) && PTR_ERR(buf) != -ENODATA)
369                 RETURN(PTR_ERR(buf));
370
371         lbuf->lb_buf = buf;
372         lbuf->lb_len = buf_len;
373
374         tmp = object_update_param_get(update, 2, &size);
375         if (IS_ERR(tmp) || size != sizeof(*tmp)) {
376                 CERROR("%s: emptry or wrong size %zu flag: rc = %ld\n",
377                        tgt_name(tsi->tsi_tgt), size, PTR_ERR(tmp));
378                 RETURN(PTR_ERR(tmp));
379         }
380
381         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
382                 __swab32s(tmp);
383         flag = *tmp;
384
385         rc = out_tx_xattr_set(tsi->tsi_env, obj, lbuf, name, flag,
386                               &tti->tti_tea, tti->tti_tea.ta_handle,
387                               tti->tti_u.update.tti_update_reply,
388                               tti->tti_u.update.tti_update_reply_index);
389         RETURN(rc);
390 }
391
392 static int out_xattr_del(struct tgt_session_info *tsi)
393 {
394         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
395         struct object_update    *update = tti->tti_u.update.tti_update;
396         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
397         char                    *name;
398         int                      rc;
399         ENTRY;
400
401         name = object_update_param_get(update, 0, NULL);
402         if (IS_ERR(name)) {
403                 CERROR("%s: empty name for xattr set: rc = %ld\n",
404                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
405                 RETURN(PTR_ERR(name));
406         }
407
408         rc = out_tx_xattr_del(tsi->tsi_env, obj, name, &tti->tti_tea,
409                               tti->tti_tea.ta_handle,
410                               tti->tti_u.update.tti_update_reply,
411                               tti->tti_u.update.tti_update_reply_index);
412         RETURN(rc);
413 }
414
415 /**
416  * increase ref of the object
417  **/
418 static int out_ref_add(struct tgt_session_info *tsi)
419 {
420         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
421         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
422         int                      rc;
423
424         ENTRY;
425
426         rc = out_tx_ref_add(tsi->tsi_env, obj, &tti->tti_tea,
427                             tti->tti_tea.ta_handle,
428                             tti->tti_u.update.tti_update_reply,
429                             tti->tti_u.update.tti_update_reply_index);
430         RETURN(rc);
431 }
432
433 static int out_ref_del(struct tgt_session_info *tsi)
434 {
435         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
436         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
437         int                      rc;
438
439         ENTRY;
440
441         if (!lu_object_exists(&obj->do_lu))
442                 RETURN(-ENOENT);
443
444         rc = out_tx_ref_del(tsi->tsi_env, obj, &tti->tti_tea,
445                             tti->tti_tea.ta_handle,
446                             tti->tti_u.update.tti_update_reply,
447                             tti->tti_u.update.tti_update_reply_index);
448         RETURN(rc);
449 }
450
451 static int out_index_insert(struct tgt_session_info *tsi)
452 {
453         struct tgt_thread_info  *tti    = tgt_th_info(tsi->tsi_env);
454         struct object_update    *update = tti->tti_u.update.tti_update;
455         struct dt_object        *obj    = tti->tti_u.update.tti_dt_object;
456         struct dt_insert_rec    *rec    = &tti->tti_rec;
457         struct lu_fid           *fid;
458         char                    *name;
459         __u32                   *ptype;
460         int                      rc     = 0;
461         size_t                   size;
462         ENTRY;
463
464         name = object_update_param_get(update, 0, NULL);
465         if (IS_ERR(name)) {
466                 CERROR("%s: empty name for index insert: rc = %ld\n",
467                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
468                 RETURN(PTR_ERR(name));
469         }
470
471         fid = object_update_param_get(update, 1, &size);
472         if (IS_ERR(fid) || size != sizeof(*fid)) {
473                 CERROR("%s: invalid fid: rc = %ld\n",
474                        tgt_name(tsi->tsi_tgt), PTR_ERR(fid));
475                 RETURN(PTR_ERR(fid));
476         }
477
478         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
479                 lustre_swab_lu_fid(fid);
480
481         if (!fid_is_sane(fid)) {
482                 CERROR("%s: invalid FID "DFID": rc = %d\n",
483                        tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO);
484                 RETURN(-EPROTO);
485         }
486
487         ptype = object_update_param_get(update, 2, &size);
488         if (IS_ERR(ptype) || size != sizeof(*ptype)) {
489                 CERROR("%s: invalid type for index insert: rc = %ld\n",
490                        tgt_name(tsi->tsi_tgt), PTR_ERR(ptype));
491                 RETURN(PTR_ERR(ptype));
492         }
493
494         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
495                 __swab32s(ptype);
496
497         rec->rec_fid = fid;
498         rec->rec_type = *ptype;
499
500         rc = out_tx_index_insert(tsi->tsi_env, obj, (const struct dt_rec *)rec,
501                                  (const struct dt_key *)name, &tti->tti_tea,
502                                  tti->tti_tea.ta_handle,
503                                  tti->tti_u.update.tti_update_reply,
504                                  tti->tti_u.update.tti_update_reply_index);
505         RETURN(rc);
506 }
507
508 static int out_index_delete(struct tgt_session_info *tsi)
509 {
510         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
511         struct object_update    *update = tti->tti_u.update.tti_update;
512         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
513         char                    *name;
514         int                      rc = 0;
515
516         if (!lu_object_exists(&obj->do_lu))
517                 RETURN(-ENOENT);
518
519         name = object_update_param_get(update, 0, NULL);
520         if (IS_ERR(name)) {
521                 CERROR("%s: empty name for index delete: rc = %ld\n",
522                        tgt_name(tsi->tsi_tgt), PTR_ERR(name));
523                 RETURN(PTR_ERR(name));
524         }
525
526         rc = out_tx_index_delete(tsi->tsi_env, obj, (const struct dt_key *)name,
527                                  &tti->tti_tea, tti->tti_tea.ta_handle,
528                                  tti->tti_u.update.tti_update_reply,
529                                  tti->tti_u.update.tti_update_reply_index);
530         RETURN(rc);
531 }
532
533 static int out_destroy(struct tgt_session_info *tsi)
534 {
535         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
536         struct object_update    *update = tti->tti_u.update.tti_update;
537         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
538         struct lu_fid           *fid;
539         int                      rc;
540         ENTRY;
541
542         fid = &update->ou_fid;
543         if (!fid_is_sane(fid)) {
544                 CERROR("%s: invalid FID "DFID": rc = %d\n",
545                        tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO);
546                 RETURN(-EPROTO);
547         }
548
549         if (!lu_object_exists(&obj->do_lu))
550                 RETURN(-ENOENT);
551
552         rc = out_tx_destroy(tsi->tsi_env, obj, &tti->tti_tea,
553                             tti->tti_tea.ta_handle,
554                             tti->tti_u.update.tti_update_reply,
555                             tti->tti_u.update.tti_update_reply_index);
556
557         RETURN(rc);
558 }
559
560 static int out_write(struct tgt_session_info *tsi)
561 {
562         struct tgt_thread_info  *tti = tgt_th_info(tsi->tsi_env);
563         struct object_update    *update = tti->tti_u.update.tti_update;
564         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
565         struct lu_buf           *lbuf = &tti->tti_buf;
566         char                    *buf;
567         __u64                   *tmp;
568         size_t                  size = 0;
569         size_t                  buf_len = 0;
570         loff_t                  pos;
571         int                      rc;
572         ENTRY;
573
574         buf = object_update_param_get(update, 0, &buf_len);
575         if (IS_ERR(buf) || buf_len == 0) {
576                 CERROR("%s: empty buf for xattr set: rc = %ld\n",
577                        tgt_name(tsi->tsi_tgt), PTR_ERR(buf));
578                 RETURN(PTR_ERR(buf));
579         }
580         lbuf->lb_buf = buf;
581         lbuf->lb_len = buf_len;
582
583         tmp = object_update_param_get(update, 1, &size);
584         if (IS_ERR(tmp) || size != sizeof(*tmp)) {
585                 CERROR("%s: empty or wrong size %zu pos: rc = %ld\n",
586                        tgt_name(tsi->tsi_tgt), size, PTR_ERR(tmp));
587                 RETURN(PTR_ERR(tmp));
588         }
589
590         if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req))
591                 __swab64s(tmp);
592         pos = *tmp;
593
594         rc = out_tx_write(tsi->tsi_env, obj, lbuf, pos,
595                           &tti->tti_tea, tti->tti_tea.ta_handle,
596                           tti->tti_u.update.tti_update_reply,
597                           tti->tti_u.update.tti_update_reply_index);
598         RETURN(rc);
599 }
600
601 static int out_read(struct tgt_session_info *tsi)
602 {
603         const struct lu_env     *env = tsi->tsi_env;
604         struct tgt_thread_info  *tti = tgt_th_info(env);
605         struct object_update    *update = tti->tti_u.update.tti_update;
606         struct dt_object        *obj = tti->tti_u.update.tti_dt_object;
607         struct object_update_reply *reply = tti->tti_u.update.tti_update_reply;
608         int index = tti->tti_u.update.tti_update_reply_index;
609         struct lu_rdbuf *rdbuf;
610         struct object_update_result *update_result;
611         struct out_read_reply   *orr;
612         void *tmp;
613         size_t size;
614         size_t total_size = 0;
615         __u64 pos;
616         unsigned int i;
617         unsigned int nbufs;
618         int rc = 0;
619         ENTRY;
620
621         update_result = object_update_result_get(reply, index, NULL);
622         LASSERT(update_result != NULL);
623         update_result->our_datalen = sizeof(*orr);
624
625         if (!lu_object_exists(&obj->do_lu))
626                 GOTO(out, rc = -ENOENT);
627
628         tmp = object_update_param_get(update, 0, NULL);
629         if (IS_ERR(tmp)) {
630                 CERROR("%s: empty size for read: rc = %ld\n",
631                        tgt_name(tsi->tsi_tgt), PTR_ERR(tmp));
632                 GOTO(out, rc = PTR_ERR(tmp));
633         }
634         size = le64_to_cpu(*(size_t *)(tmp));
635
636         tmp = object_update_param_get(update, 1, NULL);
637         if (IS_ERR(tmp)) {
638                 CERROR("%s: empty pos for read: rc = %ld\n",
639                        tgt_name(tsi->tsi_tgt), PTR_ERR(tmp));
640                 GOTO(out, rc = PTR_ERR(tmp));
641         }
642         pos = le64_to_cpu(*(__u64 *)(tmp));
643
644         /* Put the offset into the begining of the buffer in reply */
645         orr = (struct out_read_reply *)update_result->our_data;
646
647         nbufs = (size + OUT_BULK_BUFFER_SIZE - 1) / OUT_BULK_BUFFER_SIZE;
648         OBD_ALLOC(rdbuf, sizeof(struct lu_rdbuf) +
649                          nbufs * sizeof(rdbuf->rb_bufs[0]));
650         if (rdbuf == NULL)
651                 GOTO(out, rc = -ENOMEM);
652
653         rdbuf->rb_nbufs = 0;
654         total_size = 0;
655         for (i = 0; i < nbufs; i++) {
656                 __u32 read_size;
657
658                 read_size = size > OUT_BULK_BUFFER_SIZE ?
659                             OUT_BULK_BUFFER_SIZE : size;
660                 OBD_ALLOC(rdbuf->rb_bufs[i].lb_buf, read_size);
661                 if (rdbuf->rb_bufs[i].lb_buf == NULL)
662                         GOTO(out_free, rc = -ENOMEM);
663
664                 rdbuf->rb_bufs[i].lb_len = read_size;
665                 dt_read_lock(env, obj, MOR_TGT_CHILD);
666                 rc = dt_read(env, obj, &rdbuf->rb_bufs[i], &pos);
667                 dt_read_unlock(env, obj);
668
669                 total_size += rc < 0 ? 0 : rc;
670                 if (rc <= 0)
671                         break;
672
673                 rdbuf->rb_nbufs++;
674                 size -= read_size;
675         }
676
677         /* send pages to client */
678         rc = tgt_send_buffer(tsi, rdbuf);
679         if (rc < 0)
680                 GOTO(out_free, rc);
681
682         orr->orr_size = total_size;
683         orr->orr_offset = pos;
684
685         orr_cpu_to_le(orr, orr);
686         update_result->our_datalen += orr->orr_size;
687 out_free:
688         for (i = 0; i < nbufs; i++) {
689                 if (rdbuf->rb_bufs[i].lb_buf != NULL) {
690                         OBD_FREE(rdbuf->rb_bufs[i].lb_buf,
691                                  rdbuf->rb_bufs[i].lb_len);
692                 }
693         }
694         OBD_FREE(rdbuf, sizeof(struct lu_rdbuf) +
695                         nbufs * sizeof(rdbuf->rb_bufs[0]));
696 out:
697         /* Insert read buffer */
698         update_result->our_rc = ptlrpc_status_hton(rc);
699         reply->ourp_lens[index] = cfs_size_round(update_result->our_datalen +
700                                                  sizeof(*update_result));
701         RETURN(rc);
702 }
703
704 static int out_noop(struct tgt_session_info *tsi)
705 {
706         return 0;
707 }
708
709 #define DEF_OUT_HNDL(opc, name, flags, fn)     \
710 [opc - OUT_CREATE] = {                                  \
711         .th_name    = name,                             \
712         .th_fail_id = 0,                                \
713         .th_opc     = opc,                              \
714         .th_flags   = flags,                            \
715         .th_act     = fn,                               \
716         .th_fmt     = NULL,                             \
717         .th_version = 0,                                \
718 }
719
720 static struct tgt_handler out_update_ops[] = {
721         DEF_OUT_HNDL(OUT_CREATE, "out_create", MUTABOR | HABEO_REFERO,
722                      out_create),
723         DEF_OUT_HNDL(OUT_DESTROY, "out_create", MUTABOR | HABEO_REFERO,
724                      out_destroy),
725         DEF_OUT_HNDL(OUT_REF_ADD, "out_ref_add", MUTABOR | HABEO_REFERO,
726                      out_ref_add),
727         DEF_OUT_HNDL(OUT_REF_DEL, "out_ref_del", MUTABOR | HABEO_REFERO,
728                      out_ref_del),
729         DEF_OUT_HNDL(OUT_ATTR_SET, "out_attr_set",  MUTABOR | HABEO_REFERO,
730                      out_attr_set),
731         DEF_OUT_HNDL(OUT_ATTR_GET, "out_attr_get",  HABEO_REFERO,
732                      out_attr_get),
733         DEF_OUT_HNDL(OUT_XATTR_SET, "out_xattr_set", MUTABOR | HABEO_REFERO,
734                      out_xattr_set),
735         DEF_OUT_HNDL(OUT_XATTR_DEL, "out_xattr_del", MUTABOR | HABEO_REFERO,
736                      out_xattr_del),
737         DEF_OUT_HNDL(OUT_XATTR_GET, "out_xattr_get", HABEO_REFERO,
738                      out_xattr_get),
739         DEF_OUT_HNDL(OUT_INDEX_LOOKUP, "out_index_lookup", HABEO_REFERO,
740                      out_index_lookup),
741         DEF_OUT_HNDL(OUT_INDEX_INSERT, "out_index_insert",
742                      MUTABOR | HABEO_REFERO, out_index_insert),
743         DEF_OUT_HNDL(OUT_INDEX_DELETE, "out_index_delete",
744                      MUTABOR | HABEO_REFERO, out_index_delete),
745         DEF_OUT_HNDL(OUT_WRITE, "out_write", MUTABOR | HABEO_REFERO, out_write),
746         DEF_OUT_HNDL(OUT_READ, "out_read", HABEO_REFERO, out_read),
747         DEF_OUT_HNDL(OUT_NOOP, "out_noop", HABEO_REFERO, out_noop),
748 };
749
750 static struct tgt_handler *out_handler_find(__u32 opc)
751 {
752         struct tgt_handler *h;
753
754         h = NULL;
755         if (OUT_CREATE <= opc && opc < OUT_LAST) {
756                 h = &out_update_ops[opc - OUT_CREATE];
757                 LASSERTF(h->th_opc == opc, "opcode mismatch %d != %d\n",
758                          h->th_opc, opc);
759         } else {
760                 h = NULL; /* unsupported opc */
761         }
762         return h;
763 }
764
765 static int out_tx_start(const struct lu_env *env, struct dt_device *dt,
766                         struct thandle_exec_args *ta, struct obd_export *exp)
767 {
768         ta->ta_argno = 0;
769         ta->ta_handle = dt_trans_create(env, dt);
770         if (IS_ERR(ta->ta_handle)) {
771                 int rc;
772
773                 rc = PTR_ERR(ta->ta_handle);
774                 ta->ta_handle = NULL;
775                 CERROR("%s: start handle error: rc = %d\n", dt_obd_name(dt),
776                        rc);
777                 return rc;
778         }
779         if (exp->exp_need_sync)
780                 ta->ta_handle->th_sync = 1;
781
782         return 0;
783 }
784
785 static int out_trans_start(const struct lu_env *env,
786                            struct thandle_exec_args *ta)
787 {
788         return dt_trans_start(env, ta->ta_handle->th_dev, ta->ta_handle);
789 }
790
791 static int out_trans_stop(const struct lu_env *env,
792                           struct thandle_exec_args *ta, int err)
793 {
794         int i;
795         int rc;
796
797         ta->ta_handle->th_result = err;
798         rc = dt_trans_stop(env, ta->ta_handle->th_dev, ta->ta_handle);
799         for (i = 0; i < ta->ta_argno; i++) {
800                 if (ta->ta_args[i]->object != NULL) {
801                         struct dt_object *obj = ta->ta_args[i]->object;
802
803                         /* If the object is being created during this
804                          * transaction, we need to remove them from the
805                          * cache immediately, because a few layers are
806                          * missing in OUT handler, i.e. the object might
807                          * not be initialized in all layers */
808                         if (ta->ta_args[i]->exec_fn == out_tx_create_exec)
809                                 set_bit(LU_OBJECT_HEARD_BANSHEE,
810                                         &obj->do_lu.lo_header->loh_flags);
811                         lu_object_put(env, &ta->ta_args[i]->object->do_lu);
812                         ta->ta_args[i]->object = NULL;
813                 }
814         }
815         ta->ta_handle = NULL;
816         ta->ta_argno = 0;
817
818         return rc;
819 }
820
821 static int out_tx_end(const struct lu_env *env, struct thandle_exec_args *ta,
822                       int declare_ret)
823 {
824         struct tgt_session_info *tsi = tgt_ses_info(env);
825         int                     i;
826         int                     rc;
827         int                     rc1;
828         ENTRY;
829
830         if (ta->ta_handle == NULL)
831                 RETURN(0);
832
833         if (declare_ret != 0 || ta->ta_argno == 0)
834                 GOTO(stop, rc = declare_ret);
835
836         LASSERT(ta->ta_handle->th_dev != NULL);
837         rc = out_trans_start(env, ta);
838         if (unlikely(rc != 0))
839                 GOTO(stop, rc);
840
841         for (i = 0; i < ta->ta_argno; i++) {
842                 rc = ta->ta_args[i]->exec_fn(env, ta->ta_handle,
843                                              ta->ta_args[i]);
844                 if (unlikely(rc != 0)) {
845                         CDEBUG(D_INFO, "error during execution of #%u from"
846                                " %s:%d: rc = %d\n", i, ta->ta_args[i]->file,
847                                ta->ta_args[i]->line, rc);
848                         while (--i >= 0) {
849                                 if (ta->ta_args[i]->undo_fn != NULL)
850                                         ta->ta_args[i]->undo_fn(env,
851                                                                ta->ta_handle,
852                                                                ta->ta_args[i]);
853                                 else
854                                         CERROR("%s: undo for %s:%d: rc = %d\n",
855                                              dt_obd_name(ta->ta_handle->th_dev),
856                                                ta->ta_args[i]->file,
857                                                ta->ta_args[i]->line, -ENOTSUPP);
858                         }
859                         break;
860                 }
861                 CDEBUG(D_INFO, "%s: executed %u/%u: rc = %d\n",
862                        dt_obd_name(ta->ta_handle->th_dev), i, ta->ta_argno, rc);
863         }
864
865         /* Only fail for real updates, XXX right now llog updates will be
866         * ignore, whose updates count is usually 1, so failover test
867         * case will spot this FAIL_UPDATE_NET_REP precisely, and it will
868         * be removed after async update patch is landed. */
869         if (ta->ta_argno > 1)
870                 tsi->tsi_reply_fail_id = OBD_FAIL_OUT_UPDATE_NET_REP;
871
872 stop:
873         rc1 = out_trans_stop(env, ta, rc);
874         if (rc == 0)
875                 rc = rc1;
876
877         ta->ta_handle = NULL;
878         ta->ta_argno = 0;
879
880         RETURN(rc);
881 }
882
883 /**
884  * Object updates between Targets. Because all the updates has been
885  * dis-assemblied into object updates at sender side, so OUT will
886  * call OSD API directly to execute these updates.
887  *
888  * In DNE phase I all of the updates in the request need to be executed
889  * in one transaction, and the transaction has to be synchronously.
890  *
891  * Please refer to lustre/include/lustre/lustre_idl.h for req/reply
892  * format.
893  */
894 int out_handle(struct tgt_session_info *tsi)
895 {
896         const struct lu_env             *env = tsi->tsi_env;
897         struct tgt_thread_info          *tti = tgt_th_info(env);
898         struct thandle_exec_args        *ta = &tti->tti_tea;
899         struct req_capsule              *pill = tsi->tsi_pill;
900         struct dt_device                *dt = tsi->tsi_tgt->lut_bottom;
901         struct out_update_header        *ouh;
902         struct out_update_buffer        *oub = NULL;
903         struct object_update            *update;
904         struct object_update_reply      *reply;
905         struct ptlrpc_bulk_desc         *desc = NULL;
906         struct l_wait_info              lwi;
907         void                            **update_bufs;
908         int                             current_batchid = -1;
909         __u32                           update_buf_count;
910         unsigned int                    i;
911         unsigned int                    reply_index = 0;
912         int                             rc = 0;
913         int                             rc1 = 0;
914         int                             ouh_size, reply_size;
915         int                             updates;
916         ENTRY;
917
918         req_capsule_set(pill, &RQF_OUT_UPDATE);
919         ouh_size = req_capsule_get_size(pill, &RMF_OUT_UPDATE_HEADER,
920                                         RCL_CLIENT);
921         if (ouh_size <= 0)
922                 RETURN(err_serious(-EPROTO));
923
924         ouh = req_capsule_client_get(pill, &RMF_OUT_UPDATE_HEADER);
925         if (ouh == NULL)
926                 RETURN(err_serious(-EPROTO));
927
928         if (ouh->ouh_magic != OUT_UPDATE_HEADER_MAGIC) {
929                 CERROR("%s: invalid update buffer magic %x expect %x: "
930                        "rc = %d\n", tgt_name(tsi->tsi_tgt), ouh->ouh_magic,
931                        UPDATE_REQUEST_MAGIC, -EPROTO);
932                 RETURN(err_serious(-EPROTO));
933         }
934
935         update_buf_count = ouh->ouh_count;
936         if (update_buf_count == 0)
937                 RETURN(err_serious(-EPROTO));
938
939         OBD_ALLOC(update_bufs, sizeof(*update_bufs) * update_buf_count);
940         if (update_bufs == NULL)
941                 RETURN(err_serious(-ENOMEM));
942
943         if (ouh->ouh_inline_length > 0) {
944                 update_bufs[0] = ouh->ouh_inline_data;
945         } else {
946                 struct out_update_buffer *tmp;
947
948                 oub = req_capsule_client_get(pill, &RMF_OUT_UPDATE_BUF);
949                 if (oub == NULL)
950                         GOTO(out_free, rc = err_serious(-EPROTO));
951
952                 desc = ptlrpc_prep_bulk_exp(pill->rc_req, update_buf_count,
953                                             PTLRPC_BULK_OPS_COUNT,
954                                             PTLRPC_BULK_GET_SINK |
955                                             PTLRPC_BULK_BUF_KVEC,
956                                             MDS_BULK_PORTAL,
957                                             &ptlrpc_bulk_kvec_ops);
958                 if (desc == NULL)
959                         GOTO(out_free, rc = err_serious(-ENOMEM));
960
961                 tmp = oub;
962                 for (i = 0; i < update_buf_count; i++, tmp++) {
963                         if (tmp->oub_size >= OUT_MAXREQSIZE)
964                                 GOTO(out_free, rc = err_serious(-EPROTO));
965
966                         OBD_ALLOC(update_bufs[i], tmp->oub_size);
967                         if (update_bufs[i] == NULL)
968                                 GOTO(out_free, rc = err_serious(-ENOMEM));
969
970                         desc->bd_frag_ops->add_iov_frag(desc, update_bufs[i],
971                                                         tmp->oub_size);
972                 }
973
974                 pill->rc_req->rq_bulk_write = 1;
975                 rc = sptlrpc_svc_prep_bulk(pill->rc_req, desc);
976                 if (rc != 0)
977                         GOTO(out_free, rc = err_serious(rc));
978
979                 rc = target_bulk_io(pill->rc_req->rq_export, desc, &lwi);
980                 if (rc < 0)
981                         GOTO(out_free, rc = err_serious(rc));
982         }
983         /* validate the request and calculate the total update count and
984          * set it to reply */
985         reply_size = 0;
986         updates = 0;
987         for (i = 0; i < update_buf_count; i++) {
988                 struct object_update_request    *our;
989                 int                              j;
990
991                 our = update_bufs[i];
992                 if (ptlrpc_req_need_swab(pill->rc_req))
993                         lustre_swab_object_update_request(our);
994
995                 if (our->ourq_magic != UPDATE_REQUEST_MAGIC) {
996                         CERROR("%s: invalid update buffer magic %x"
997                                " expect %x: rc = %d\n",
998                                tgt_name(tsi->tsi_tgt), our->ourq_magic,
999                                UPDATE_REQUEST_MAGIC, -EPROTO);
1000                         GOTO(out_free, rc = err_serious(-EPROTO));
1001                 }
1002                 updates += our->ourq_count;
1003
1004                 /* need to calculate reply size */
1005                 for (j = 0; j < our->ourq_count; j++) {
1006                         update = object_update_request_get(our, j, NULL);
1007                         if (update == NULL)
1008                                 GOTO(out, rc = err_serious(-EPROTO));
1009                         if (ptlrpc_req_need_swab(pill->rc_req))
1010                                 lustre_swab_object_update(update);
1011
1012                         if (!fid_is_sane(&update->ou_fid)) {
1013                                 CERROR("%s: invalid FID "DFID": rc = %d\n",
1014                                        tgt_name(tsi->tsi_tgt),
1015                                        PFID(&update->ou_fid), -EPROTO);
1016                                 GOTO(out, rc = err_serious(-EPROTO));
1017                         }
1018
1019                         /* XXX: what ou_result_size can be considered safe? */
1020
1021                         reply_size += sizeof(reply->ourp_lens[0]);
1022                         reply_size += sizeof(struct object_update_result);
1023                         reply_size += update->ou_result_size;
1024                 }
1025         }
1026         reply_size += sizeof(*reply);
1027
1028         if (unlikely(reply_size > ouh->ouh_reply_size)) {
1029                 CERROR("%s: too small reply buf %u for %u, need %u at least\n",
1030                        tgt_name(tsi->tsi_tgt), ouh->ouh_reply_size,
1031                        updates, reply_size);
1032                 GOTO(out_free, rc = err_serious(-EPROTO));
1033         }
1034
1035         req_capsule_set_size(pill, &RMF_OUT_UPDATE_REPLY, RCL_SERVER,
1036                              ouh->ouh_reply_size);
1037         rc = req_capsule_server_pack(pill);
1038         if (rc != 0) {
1039                 CERROR("%s: Can't pack response: rc = %d\n",
1040                        tgt_name(tsi->tsi_tgt), rc);
1041                 GOTO(out_free, rc = err_serious(-EPROTO));
1042         }
1043
1044         /* Prepare the update reply buffer */
1045         reply = req_capsule_server_get(pill, &RMF_OUT_UPDATE_REPLY);
1046         if (reply == NULL)
1047                 GOTO(out_free, rc = -EPROTO);
1048         reply->ourp_magic = UPDATE_REPLY_MAGIC;
1049         reply->ourp_count = updates;
1050         tti->tti_u.update.tti_update_reply = reply;
1051         tti->tti_mult_trans = !req_is_replay(tgt_ses_req(tsi));
1052  
1053         /* Walk through updates in the request to execute them */
1054         for (i = 0; i < update_buf_count; i++) {
1055                 struct tgt_handler      *h;
1056                 struct dt_object        *dt_obj;
1057                 int                     update_count;
1058                 struct object_update_request *our;
1059                 int                     j;
1060
1061                 our = update_bufs[i];
1062                 update_count = our->ourq_count;
1063                 for (j = 0; j < update_count; j++) {
1064                         update = object_update_request_get(our, j, NULL);
1065
1066                         dt_obj = dt_locate(env, dt, &update->ou_fid);
1067                         if (IS_ERR(dt_obj))
1068                                 GOTO(out, rc = PTR_ERR(dt_obj));
1069
1070                         if (dt->dd_record_fid_accessed) {
1071                                 lfsck_pack_rfa(&tti->tti_lr,
1072                                                lu_object_fid(&dt_obj->do_lu),
1073                                                LE_FID_ACCESSED,
1074                                                LFSCK_TYPE_LAYOUT);
1075                                 tgt_lfsck_in_notify(env, dt, &tti->tti_lr,
1076                                                     NULL);
1077                         }
1078
1079                         tti->tti_u.update.tti_dt_object = dt_obj;
1080                         tti->tti_u.update.tti_update = update;
1081                         tti->tti_u.update.tti_update_reply_index = reply_index;
1082
1083                         h = out_handler_find(update->ou_type);
1084                         if (unlikely(h == NULL)) {
1085                                 CERROR("%s: unsupported opc: 0x%x\n",
1086                                        tgt_name(tsi->tsi_tgt), update->ou_type);
1087                                 GOTO(next, rc = -ENOTSUPP);
1088                         }
1089
1090                         /* Check resend case only for modifying RPC */
1091                         if (h->th_flags & MUTABOR) {
1092                                 struct ptlrpc_request *req = tgt_ses_req(tsi);
1093
1094                                 if (out_check_resent(env, dt, dt_obj, req,
1095                                                      out_reconstruct, reply,
1096                                                      reply_index))
1097                                         GOTO(next, rc = 0);
1098                         }
1099
1100                         /* start transaction for modification RPC only */
1101                         if (h->th_flags & MUTABOR && current_batchid == -1) {
1102                                 current_batchid = update->ou_batchid;
1103                                 rc = out_tx_start(env, dt, ta, tsi->tsi_exp);
1104                                 if (rc != 0)
1105                                         GOTO(next, rc);
1106
1107                                 if (update->ou_flags & UPDATE_FL_SYNC)
1108                                         ta->ta_handle->th_sync = 1;
1109                         }
1110
1111                         /* Stop the current update transaction, if the update
1112                          * has different batchid, or read-only update */
1113                         if (((current_batchid != update->ou_batchid) ||
1114                              !(h->th_flags & MUTABOR)) &&
1115                              ta->ta_handle != NULL) {
1116                                 rc = out_tx_end(env, ta, rc);
1117                                 current_batchid = -1;
1118                                 if (rc != 0)
1119                                         GOTO(next, rc);
1120
1121                                 /* start a new transaction if needed */
1122                                 if (h->th_flags & MUTABOR) {
1123                                         rc = out_tx_start(env, dt, ta,
1124                                                           tsi->tsi_exp);
1125                                         if (rc != 0)
1126                                                 GOTO(next, rc);
1127                                         if (update->ou_flags & UPDATE_FL_SYNC)
1128                                                 ta->ta_handle->th_sync = 1;
1129                                         current_batchid = update->ou_batchid;
1130                                 }
1131                         }
1132
1133                         rc = h->th_act(tsi);
1134 next:
1135                         reply_index++;
1136                         lu_object_put(env, &dt_obj->do_lu);
1137                         if (rc < 0)
1138                                 GOTO(out, rc);
1139                 }
1140         }
1141 out:
1142         if (current_batchid != -1) {
1143                 rc1 = out_tx_end(env, ta, rc);
1144                 if (rc == 0)
1145                         rc = rc1;
1146         }
1147
1148 out_free:
1149         if (update_bufs != NULL) {
1150                 if (oub != NULL) {
1151                         for (i = 0; i < update_buf_count; i++, oub++) {
1152                                 if (update_bufs[i] != NULL)
1153                                         OBD_FREE(update_bufs[i], oub->oub_size);
1154                         }
1155                 }
1156
1157                 OBD_FREE(update_bufs, sizeof(*update_bufs) * update_buf_count);
1158         }
1159
1160         if (desc != NULL)
1161                 ptlrpc_free_bulk(desc);
1162
1163         RETURN(rc);
1164 }
1165
1166 struct tgt_handler tgt_out_handlers[] = {
1167 TGT_UPDATE_HDL(MUTABOR, OUT_UPDATE,     out_handle),
1168 };
1169 EXPORT_SYMBOL(tgt_out_handlers);
1170