Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / include / lustre_update.h
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.htm
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2013, 2016, Intel Corporation.
24  */
25 /*
26  * lustre/include/lustre_update.h
27  *
28  * Author: Di Wang <di.wang@intel.com>
29  */
30
31 #ifndef _LUSTRE_UPDATE_H
32 #define _LUSTRE_UPDATE_H
33 #include <dt_object.h>
34 #include <lustre_net.h>
35 #include <obj_update.h>
36
37 #define OUT_UPDATE_INIT_BUFFER_SIZE     4096
38 #define OUT_UPDATE_REPLY_SIZE           4096
39 #define OUT_BULK_BUFFER_SIZE            4096
40
41 struct dt_key;
42 struct dt_rec;
43 struct object_update_param;
44 struct llog_update_record;
45
46 static inline size_t update_params_size(const struct update_params *params,
47                                         unsigned int param_count)
48 {
49         struct object_update_param      *param;
50         size_t total_size = sizeof(*params);
51         unsigned int i;
52
53         param = (struct object_update_param *)&params->up_params[0];
54         for (i = 0; i < param_count; i++) {
55                 size_t size = object_update_param_size(param);
56
57                 param = (struct object_update_param *)((char *)param + size);
58                 total_size += size;
59         }
60
61         return total_size;
62 }
63
64 static inline struct object_update_param *
65 update_params_get_param(const struct update_params *params,
66                         unsigned int index, unsigned int param_count)
67 {
68         struct object_update_param *param;
69         unsigned int            i;
70
71         if (index > param_count)
72                 return NULL;
73
74         param = (struct object_update_param *)&params->up_params[0];
75         for (i = 0; i < index; i++)
76                 param = (struct object_update_param *)((char *)param +
77                         object_update_param_size(param));
78
79         return param;
80 }
81
82 static inline void*
83 update_params_get_param_buf(const struct update_params *params, __u16 index,
84                             unsigned int param_count, __u16 *size)
85 {
86         struct object_update_param *param;
87
88         param = update_params_get_param(params, (unsigned int)index,
89                                         param_count);
90         if (param == NULL)
91                 return NULL;
92
93         if (size != NULL)
94                 *size = param->oup_len;
95
96         return param->oup_buf;
97 }
98
99 static inline size_t
100 update_op_size(unsigned int param_count)
101 {
102         return offsetof(struct update_op, uop_params_off[param_count]);
103 }
104
105 static inline struct update_op *
106 update_op_next_op(const struct update_op *uop)
107 {
108         return (struct update_op *)((char *)uop +
109                                 update_op_size(uop->uop_param_count));
110 }
111
112 static inline size_t update_ops_size(const struct update_ops *ops,
113                                      unsigned int update_count)
114 {
115         struct update_op *op;
116         size_t total_size = sizeof(*ops);
117         unsigned int i;
118
119         op = (struct update_op *)&ops->uops_op[0];
120         for (i = 0; i < update_count; i++, op = update_op_next_op(op))
121                 total_size += update_op_size(op->uop_param_count);
122
123         return total_size;
124 }
125
126 static inline struct update_params *
127 update_records_get_params(const struct update_records *record)
128 {
129         return (struct update_params *)((char *)record +
130                 offsetof(struct update_records, ur_ops) +
131                 update_ops_size(&record->ur_ops, record->ur_update_count));
132 }
133
134 static inline struct update_param *
135 update_param_next_param(const struct update_param *param)
136 {
137         return (struct update_param *)((char *)param +
138                                        object_update_param_size(
139                                           (struct object_update_param *)param));
140 }
141
142 static inline size_t
143 __update_records_size(size_t raw_size)
144 {
145         return cfs_size_round(offsetof(struct update_records, ur_ops) +
146                               raw_size);
147 }
148
149 static inline size_t
150 update_records_size(const struct update_records *record)
151 {
152         size_t op_size = 0;
153         size_t param_size = 0;
154
155         if (record->ur_update_count > 0)
156                 op_size = update_ops_size(&record->ur_ops,
157                                           record->ur_update_count);
158         if (record->ur_param_count > 0) {
159                 struct update_params *params;
160
161                 params = update_records_get_params(record);
162                 param_size = update_params_size(params, record->ur_param_count);
163         }
164
165         return __update_records_size(op_size + param_size);
166 }
167
168 static inline size_t
169 __llog_update_record_size(size_t records_size)
170 {
171         return cfs_size_round(sizeof(struct llog_rec_hdr) + records_size +
172                               sizeof(struct llog_rec_tail));
173 }
174
175 static inline size_t
176 llog_update_record_size(const struct llog_update_record *lur)
177 {
178         return __llog_update_record_size(
179                         update_records_size(&lur->lur_update_rec));
180 }
181
182 static inline struct update_op *
183 update_ops_get_op(const struct update_ops *ops, unsigned int index,
184                   unsigned int update_count)
185 {
186         struct update_op *op;
187         unsigned int i;
188
189         if (index > update_count)
190                 return NULL;
191
192         op = (struct update_op *)&ops->uops_op[0];
193         for (i = 0; i < index; i++)
194                 op = update_op_next_op(op);
195
196         return op;
197 }
198
199 static inline void
200 *object_update_param_get(const struct object_update *update, size_t index,
201                          size_t *size)
202 {
203         const struct    object_update_param *param;
204         size_t          i;
205
206         if (index >= update->ou_params_count)
207                 return ERR_PTR(-EINVAL);
208
209         param = &update->ou_params[0];
210         for (i = 0; i < index; i++)
211                 param = (struct object_update_param *)((char *)param +
212                         object_update_param_size(param));
213
214         if (size != NULL)
215                 *size = param->oup_len;
216
217         if (param->oup_len == 0)
218                 return ERR_PTR(-ENODATA);
219
220         return (void *)&param->oup_buf[0];
221 }
222
223 static inline unsigned long
224 object_update_request_size(const struct object_update_request *our)
225 {
226         unsigned long   size;
227         size_t          i = 0;
228
229         size = offsetof(struct object_update_request, ourq_updates[0]);
230         for (i = 0; i < our->ourq_count; i++) {
231                 struct object_update *update;
232
233                 update = (struct object_update *)((char *)our + size);
234                 size += object_update_size(update);
235         }
236         return size;
237 }
238
239 static inline void
240 object_update_result_insert(struct object_update_reply *reply,
241                             void *data, size_t data_len, size_t index,
242                             int rc)
243 {
244         struct object_update_result *update_result;
245         char *ptr;
246
247         update_result = object_update_result_get(reply, index, NULL);
248         LASSERT(update_result != NULL);
249
250         update_result->our_rc = ptlrpc_status_hton(rc);
251         if (data != NULL && data_len > 0) {
252                 LASSERT(data != NULL);
253                 ptr = (char *)update_result +
254                         cfs_size_round(sizeof(struct object_update_reply));
255                 update_result->our_datalen = data_len;
256                 memcpy(ptr, data, data_len);
257         }
258
259         reply->ourp_lens[index] = cfs_size_round(data_len +
260                                         sizeof(struct object_update_result));
261 }
262
263 static inline int
264 object_update_result_data_get(const struct object_update_reply *reply,
265                               struct lu_buf *lbuf, size_t index)
266 {
267         struct object_update_result *update_result;
268         size_t size = 0;
269         int    result;
270
271         LASSERT(lbuf != NULL);
272         update_result = object_update_result_get(reply, index, &size);
273         if (update_result == NULL ||
274             size < cfs_size_round(sizeof(struct object_update_reply)) ||
275             update_result->our_datalen > size)
276                 RETURN(-EFAULT);
277
278         result = ptlrpc_status_ntoh(update_result->our_rc);
279         if (result < 0)
280                 return result;
281
282         lbuf->lb_buf = update_result->our_data;
283         lbuf->lb_len = update_result->our_datalen;
284
285         return result;
286 }
287
288 /**
289  * Attached in the thandle to record the updates for distribute
290  * distribution.
291  */
292 struct thandle_update_records {
293         /* All of updates for the cross-MDT operation, vmalloc'd. */
294         struct llog_update_record       *tur_update_records;
295         size_t                          tur_update_records_buf_size;
296
297         /* All of parameters for the cross-MDT operation, vmalloc'd */
298         struct update_params    *tur_update_params;
299         unsigned int            tur_update_param_count;
300         size_t                  tur_update_params_buf_size;
301 };
302
303 #define TOP_THANDLE_MAGIC       0x20140917
304 struct top_multiple_thandle {
305         struct dt_device        *tmt_master_sub_dt;
306         atomic_t                tmt_refcount;
307         /* Other sub transactions will be listed here. */
308         struct list_head        tmt_sub_thandle_list;
309         spinlock_t              tmt_sub_lock;
310
311         struct list_head        tmt_commit_list;
312         /* All of update records will packed here */
313         struct thandle_update_records *tmt_update_records;
314
315         wait_queue_head_t       tmt_stop_waitq;
316         __u64                   tmt_batchid;
317         int                     tmt_result;
318         __u32                   tmt_magic;
319         size_t                  tmt_record_size;
320         __u32                   tmt_committed:1;
321 };
322
323 /* {top,sub}_thandle are used to manage distributed transactions which
324  * include updates on several nodes. A top_handle represents the
325  * whole operation, and sub_thandle represents updates on each node. */
326 struct top_thandle {
327         struct thandle          tt_super;
328         /* The master sub transaction. */
329         struct thandle          *tt_master_sub_thandle;
330
331         struct top_multiple_thandle *tt_multiple_thandle;
332 };
333
334 struct sub_thandle_cookie {
335         struct llog_cookie      stc_cookie;
336         struct list_head        stc_list;
337 };
338
339 /* Sub thandle is used to track multiple sub thandles under one parent
340  * thandle */
341 struct sub_thandle {
342         struct thandle          *st_sub_th;
343         struct dt_device        *st_dt;
344         struct list_head        st_cookie_list;
345         struct dt_txn_commit_cb st_commit_dcb;
346         struct dt_txn_commit_cb st_stop_dcb;
347         int                     st_result;
348
349         /* linked to top_thandle */
350         struct list_head        st_sub_list;
351
352         /* If this sub thandle is committed */
353         bool                    st_committed:1,
354                                 st_stopped:1,
355                                 st_started:1;
356 };
357
358 struct tx_arg;
359 typedef int (*tx_exec_func_t)(const struct lu_env *env, struct thandle *th,
360                               struct tx_arg *ta);
361
362 /* Structure for holding one update execution */
363 struct tx_arg {
364         tx_exec_func_t           exec_fn;
365         tx_exec_func_t           undo_fn;
366         struct dt_object        *object;
367         const char              *file;
368         struct object_update_reply *reply;
369         int                      line;
370         int                      index;
371         union {
372                 struct {
373                         struct dt_insert_rec     rec;
374                         const struct dt_key     *key;
375                 } insert;
376                 struct {
377                 } ref;
378                 struct {
379                         struct lu_attr   attr;
380                 } attr_set;
381                 struct {
382                         struct lu_buf    buf;
383                         const char      *name;
384                         int              flags;
385                         __u32            csum;
386                 } xattr_set;
387                 struct {
388                         struct lu_attr                  attr;
389                         struct dt_allocation_hint       hint;
390                         struct dt_object_format         dof;
391                         struct lu_fid                   fid;
392                 } create;
393                 struct {
394                         struct lu_buf   buf;
395                         loff_t          pos;
396                 } write;
397                 struct {
398                         struct ost_body     *body;
399                 } destroy;
400         } u;
401 };
402
403 /* Structure for holding all update executations of one transaction */
404 struct thandle_exec_args {
405         struct thandle          *ta_handle;
406         int                     ta_argno;   /* used args */
407         int                     ta_alloc_args; /* allocated args count */
408         struct tx_arg           **ta_args;
409 };
410
411 /* target/out_lib.c */
412 int out_update_pack(const struct lu_env *env, struct object_update *update,
413                     size_t *max_update_size, enum update_type op,
414                     const struct lu_fid *fid, unsigned int params_count,
415                     __u16 *param_sizes, const void **param_bufs,
416                     __u32 reply_size);
417 int out_create_pack(const struct lu_env *env, struct object_update *update,
418                     size_t *max_update_size, const struct lu_fid *fid,
419                     const struct lu_attr *attr, struct dt_allocation_hint *hint,
420                     struct dt_object_format *dof);
421 int out_object_destroy_pack(const struct lu_env *env,
422                             struct object_update *update,
423                             size_t *max_update_size,
424                             const struct lu_fid *fid);
425 int out_index_delete_pack(const struct lu_env *env,
426                           struct object_update *update, size_t *max_update_size,
427                           const struct lu_fid *fid, const struct dt_key *key);
428 int out_index_insert_pack(const struct lu_env *env,
429                           struct object_update *update, size_t *max_update_size,
430                           const struct lu_fid *fid, const struct dt_rec *rec,
431                           const struct dt_key *key);
432 int out_xattr_set_pack(const struct lu_env *env,
433                        struct object_update *update, size_t *max_update_size,
434                        const struct lu_fid *fid, const struct lu_buf *buf,
435                        const char *name, __u32 flag);
436 int out_xattr_del_pack(const struct lu_env *env,
437                        struct object_update *update, size_t *max_update_size,
438                        const struct lu_fid *fid, const char *name);
439 int out_attr_set_pack(const struct lu_env *env,
440                       struct object_update *update, size_t *max_update_size,
441                       const struct lu_fid *fid, const struct lu_attr *attr);
442 int out_ref_add_pack(const struct lu_env *env,
443                      struct object_update *update, size_t *max_update_size,
444                      const struct lu_fid *fid);
445 int out_ref_del_pack(const struct lu_env *env,
446                      struct object_update *update, size_t *max_update_size,
447                      const struct lu_fid *fid);
448 int out_write_pack(const struct lu_env *env,
449                    struct object_update *update, size_t *max_update_size,
450                    const struct lu_fid *fid, const struct lu_buf *buf,
451                    __u64 pos);
452 int out_attr_get_pack(const struct lu_env *env,
453                       struct object_update *update, size_t *max_update_size,
454                       const struct lu_fid *fid);
455 int out_index_lookup_pack(const struct lu_env *env,
456                           struct object_update *update, size_t *max_update_size,
457                           const struct lu_fid *fid, struct dt_rec *rec,
458                           const struct dt_key *key);
459 int out_xattr_get_pack(const struct lu_env *env,
460                        struct object_update *update, size_t *max_update_size,
461                        const struct lu_fid *fid, const char *name,
462                        const int bufsize);
463 int out_read_pack(const struct lu_env *env, struct object_update *update,
464                   size_t *max_update_length, const struct lu_fid *fid,
465                   size_t size, loff_t pos);
466
467 const char *update_op_str(__u16 opcode);
468
469 /* target/update_trans.c */
470 struct thandle *thandle_get_sub_by_dt(const struct lu_env *env,
471                                       struct thandle *th,
472                                       struct dt_device *sub_dt);
473
474 static inline struct thandle *
475 thandle_get_sub(const struct lu_env *env, struct thandle *th,
476                  const struct dt_object *sub_obj)
477 {
478         return thandle_get_sub_by_dt(env, th, lu2dt_dev(sub_obj->do_lu.lo_dev));
479 }
480
481 struct thandle *
482 top_trans_create(const struct lu_env *env, struct dt_device *master_dev);
483 int top_trans_start(const struct lu_env *env, struct dt_device *master_dev,
484                     struct thandle *th);
485 int top_trans_stop(const struct lu_env *env, struct dt_device *master_dev,
486                    struct thandle *th);
487 void top_multiple_thandle_destroy(struct top_multiple_thandle *tmt);
488
489 static inline void top_multiple_thandle_get(struct top_multiple_thandle *tmt)
490 {
491         atomic_inc(&tmt->tmt_refcount);
492 }
493
494 static inline void top_multiple_thandle_put(struct top_multiple_thandle *tmt)
495 {
496         if (atomic_dec_and_test(&tmt->tmt_refcount))
497                 top_multiple_thandle_destroy(tmt);
498 }
499
500 struct sub_thandle *lookup_sub_thandle(struct top_multiple_thandle *tmt,
501                                        struct dt_device *dt_dev);
502 int sub_thandle_trans_create(const struct lu_env *env,
503                              struct top_thandle *top_th,
504                              struct sub_thandle *st);
505
506 /* update_records.c */
507 size_t update_records_create_size(const struct lu_env *env,
508                                   const struct lu_fid *fid,
509                                   const struct lu_attr *attr,
510                                   const struct dt_allocation_hint *hint,
511                                   struct dt_object_format *dof);
512 size_t update_records_attr_set_size(const struct lu_env *env,
513                                     const struct lu_fid *fid,
514                                     const struct lu_attr *attr);
515 size_t update_records_ref_add_size(const struct lu_env *env,
516                                    const struct lu_fid *fid);
517 size_t update_records_ref_del_size(const struct lu_env *env,
518                                    const struct lu_fid *fid);
519 size_t update_records_object_destroy_size(const struct lu_env *env,
520                                           const struct lu_fid *fid);
521 size_t update_records_index_insert_size(const struct lu_env *env,
522                                         const struct lu_fid *fid,
523                                         const struct dt_rec *rec,
524                                         const struct dt_key *key);
525 size_t update_records_index_delete_size(const struct lu_env *env,
526                                         const struct lu_fid *fid,
527                                         const struct dt_key *key);
528 size_t update_records_xattr_set_size(const struct lu_env *env,
529                                      const struct lu_fid *fid,
530                                      const struct lu_buf *buf,
531                                      const char *name,
532                                      __u32 flag);
533 size_t update_records_xattr_del_size(const struct lu_env *env,
534                                      const struct lu_fid *fid,
535                                      const char *name);
536 size_t update_records_write_size(const struct lu_env *env,
537                                  const struct lu_fid *fid,
538                                  const struct lu_buf *buf,
539                                  __u64 pos);
540 size_t update_records_punch_size(const struct lu_env *env,
541                                  const struct lu_fid *fid,
542                                  __u64 start, __u64 end);
543
544 int update_records_create_pack(const struct lu_env *env,
545                                struct update_ops *ops,
546                                unsigned int *op_count,
547                                size_t *max_ops_size,
548                                struct update_params *params,
549                                unsigned int *param_count,
550                                size_t *max_param_size,
551                                const struct lu_fid *fid,
552                                const struct lu_attr *attr,
553                                const struct dt_allocation_hint *hint,
554                                struct dt_object_format *dof);
555 int update_records_attr_set_pack(const struct lu_env *env,
556                                  struct update_ops *ops,
557                                  unsigned int *op_count,
558                                  size_t *max_ops_size,
559                                  struct update_params *params,
560                                  unsigned int *param_count,
561                                  size_t *max_param_size,
562                                  const struct lu_fid *fid,
563                                  const struct lu_attr *attr);
564 int update_records_ref_add_pack(const struct lu_env *env,
565                                 struct update_ops *ops,
566                                 unsigned int *op_count,
567                                 size_t *max_ops_size,
568                                 struct update_params *params,
569                                 unsigned int *param_count,
570                                 size_t *max_param_size,
571                                 const struct lu_fid *fid);
572 int update_records_ref_del_pack(const struct lu_env *env,
573                                 struct update_ops *ops,
574                                 unsigned int *op_count,
575                                 size_t *max_ops_size,
576                                 struct update_params *params,
577                                 unsigned int *param_count,
578                                 size_t *max_param_size,
579                                 const struct lu_fid *fid);
580 int update_records_object_destroy_pack(const struct lu_env *env,
581                                        struct update_ops *ops,
582                                        unsigned int *op_count,
583                                        size_t *max_ops_size,
584                                        struct update_params *params,
585                                        unsigned int *param_count,
586                                        size_t *max_param_size,
587                                        const struct lu_fid *fid);
588 int update_records_index_insert_pack(const struct lu_env *env,
589                                      struct update_ops *ops,
590                                      unsigned int *op_count,
591                                      size_t *max_ops_size,
592                                      struct update_params *params,
593                                      unsigned int *param_count,
594                                      size_t *max_param_size,
595                                      const struct lu_fid *fid,
596                                      const struct dt_rec *rec,
597                                      const struct dt_key *key);
598 int update_records_index_delete_pack(const struct lu_env *env,
599                                      struct update_ops *ops,
600                                      unsigned int *op_count,
601                                      size_t *max_ops_size,
602                                      struct update_params *params,
603                                      unsigned int *param_count,
604                                      size_t *max_param_size,
605                                      const struct lu_fid *fid,
606                                      const struct dt_key *key);
607 int update_records_xattr_set_pack(const struct lu_env *env,
608                                   struct update_ops *ops,
609                                   unsigned int *op_count,
610                                   size_t *max_ops_size,
611                                   struct update_params *params,
612                                   unsigned int *param_count,
613                                   size_t *max_param_size,
614                                   const struct lu_fid *fid,
615                                   const struct lu_buf *buf, const char *name,
616                                   __u32 flag);
617 int update_records_xattr_del_pack(const struct lu_env *env,
618                                   struct update_ops *ops,
619                                   unsigned int *op_count,
620                                   size_t *max_ops_size,
621                                   struct update_params *params,
622                                   unsigned int *param_count,
623                                   size_t *max_param_size,
624                                   const struct lu_fid *fid,
625                                   const char *name);
626 int update_records_write_pack(const struct lu_env *env,
627                               struct update_ops *ops,
628                               unsigned int *op_count,
629                               size_t *max_ops_size,
630                               struct update_params *params,
631                               unsigned int *param_count,
632                               size_t *max_param_size,
633                               const struct lu_fid *fid,
634                               const struct lu_buf *buf,
635                               __u64 pos);
636 int update_records_punch_pack(const struct lu_env *env,
637                               struct update_ops *ops,
638                               unsigned int *op_count,
639                               size_t *max_ops_size,
640                               struct update_params *params,
641                               unsigned int *param_count,
642                               size_t *max_param_size,
643                               const struct lu_fid *fid,
644                               __u64 start, __u64 end);
645 int update_records_noop_pack(const struct lu_env *env,
646                              struct update_ops *ops,
647                              unsigned int *op_count,
648                              size_t *max_ops_size,
649                              struct update_params *params,
650                              unsigned int *param_count,
651                              size_t *max_param_size,
652                              const struct lu_fid *fid);
653
654 int tur_update_records_extend(struct thandle_update_records *tur,
655                               size_t new_size);
656 int tur_update_params_extend(struct thandle_update_records *tur,
657                              size_t new_size);
658 int tur_update_extend(struct thandle_update_records *tur,
659                       size_t new_op_size, size_t new_param_size);
660
661 #define update_record_pack(name, th, ...)                               \
662 ({                                                                      \
663         struct top_thandle *top_th;                                     \
664         struct top_multiple_thandle *tmt;                               \
665         struct thandle_update_records *tur;                             \
666         struct llog_update_record     *lur;                             \
667         size_t          avail_param_size;                               \
668         size_t          avail_op_size;                                  \
669         int             ret;                                            \
670                                                                         \
671         while (1) {                                                     \
672                 top_th = container_of(th, struct top_thandle, tt_super);\
673                 tmt = top_th->tt_multiple_thandle;                      \
674                 tur = tmt->tmt_update_records;                          \
675                 lur = tur->tur_update_records;                          \
676                 avail_param_size = tur->tur_update_params_buf_size -    \
677                              update_params_size(tur->tur_update_params, \
678                                         tur->tur_update_param_count);   \
679                 avail_op_size = tur->tur_update_records_buf_size -      \
680                                 llog_update_record_size(lur);           \
681                 ret = update_records_##name##_pack(env,                 \
682                                           &lur->lur_update_rec.ur_ops,  \
683                                   &lur->lur_update_rec.ur_update_count, \
684                                   &avail_op_size,                       \
685                                   tur->tur_update_params,               \
686                                   &tur->tur_update_param_count,         \
687                                   &avail_param_size, __VA_ARGS__);      \
688                 if (ret == -E2BIG) {                                    \
689                         ret = tur_update_extend(tur, avail_op_size,     \
690                                                    avail_param_size);   \
691                         if (ret != 0)                                   \
692                                 break;                                  \
693                         continue;                                       \
694                 } else {                                                \
695                         break;                                          \
696                 }                                                       \
697         }                                                               \
698         ret;                                                            \
699 })
700
701 #define update_record_size(env, name, th, ...)                          \
702 ({                                                                      \
703         struct top_thandle *top_th;                                     \
704         struct top_multiple_thandle *tmt;                               \
705                                                                         \
706         top_th = container_of(th, struct top_thandle, tt_super);        \
707                                                                         \
708         LASSERT(top_th->tt_multiple_thandle != NULL);                   \
709         tmt = top_th->tt_multiple_thandle;                              \
710         tmt->tmt_record_size +=                                         \
711                 update_records_##name##_size(env, __VA_ARGS__);         \
712 })
713 #endif