Whamcloud - gitweb
LU-10308 misc: update Intel copyright messages for 2017
[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, 2017, 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_REPLY_SIZE           4096
38 #define OUT_BULK_BUFFER_SIZE            4096
39
40 struct dt_key;
41 struct dt_rec;
42 struct object_update_param;
43 struct llog_update_record;
44
45 static inline size_t update_params_size(const struct update_params *params,
46                                         unsigned int param_count)
47 {
48         struct object_update_param      *param;
49         size_t total_size = sizeof(*params);
50         unsigned int i;
51
52         param = (struct object_update_param *)&params->up_params[0];
53         for (i = 0; i < param_count; i++) {
54                 size_t size = object_update_param_size(param);
55
56                 param = (struct object_update_param *)((char *)param + size);
57                 total_size += size;
58         }
59
60         return total_size;
61 }
62
63 static inline struct object_update_param *
64 update_params_get_param(const struct update_params *params,
65                         unsigned int index, unsigned int param_count)
66 {
67         struct object_update_param *param;
68         unsigned int            i;
69
70         if (index > param_count)
71                 return NULL;
72
73         param = (struct object_update_param *)&params->up_params[0];
74         for (i = 0; i < index; i++)
75                 param = (struct object_update_param *)((char *)param +
76                         object_update_param_size(param));
77
78         return param;
79 }
80
81 static inline void*
82 update_params_get_param_buf(const struct update_params *params, __u16 index,
83                             unsigned int param_count, __u16 *size)
84 {
85         struct object_update_param *param;
86
87         param = update_params_get_param(params, (unsigned int)index,
88                                         param_count);
89         if (param == NULL)
90                 return NULL;
91
92         if (size != NULL)
93                 *size = param->oup_len;
94
95         return param->oup_buf;
96 }
97
98 static inline size_t
99 update_op_size(unsigned int param_count)
100 {
101         return offsetof(struct update_op, uop_params_off[param_count]);
102 }
103
104 static inline struct update_op *
105 update_op_next_op(const struct update_op *uop)
106 {
107         return (struct update_op *)((char *)uop +
108                                 update_op_size(uop->uop_param_count));
109 }
110
111 static inline size_t update_ops_size(const struct update_ops *ops,
112                                      unsigned int update_count)
113 {
114         struct update_op *op;
115         size_t total_size = sizeof(*ops);
116         unsigned int i;
117
118         op = (struct update_op *)&ops->uops_op[0];
119         for (i = 0; i < update_count; i++, op = update_op_next_op(op))
120                 total_size += update_op_size(op->uop_param_count);
121
122         return total_size;
123 }
124
125 static inline struct update_params *
126 update_records_get_params(const struct update_records *record)
127 {
128         return (struct update_params *)((char *)record +
129                 offsetof(struct update_records, ur_ops) +
130                 update_ops_size(&record->ur_ops, record->ur_update_count));
131 }
132
133 static inline struct update_param *
134 update_param_next_param(const struct update_param *param)
135 {
136         return (struct update_param *)((char *)param +
137                                        object_update_param_size(
138                                           (struct object_update_param *)param));
139 }
140
141 static inline size_t
142 __update_records_size(size_t raw_size)
143 {
144         return cfs_size_round(offsetof(struct update_records, ur_ops) +
145                               raw_size);
146 }
147
148 static inline size_t
149 update_records_size(const struct update_records *record)
150 {
151         size_t op_size = 0;
152         size_t param_size = 0;
153
154         if (record->ur_update_count > 0)
155                 op_size = update_ops_size(&record->ur_ops,
156                                           record->ur_update_count);
157         if (record->ur_param_count > 0) {
158                 struct update_params *params;
159
160                 params = update_records_get_params(record);
161                 param_size = update_params_size(params, record->ur_param_count);
162         }
163
164         return __update_records_size(op_size + param_size);
165 }
166
167 static inline size_t
168 __llog_update_record_size(size_t records_size)
169 {
170         return cfs_size_round(sizeof(struct llog_rec_hdr) + records_size +
171                               sizeof(struct llog_rec_tail));
172 }
173
174 static inline size_t
175 llog_update_record_size(const struct llog_update_record *lur)
176 {
177         return __llog_update_record_size(
178                         update_records_size(&lur->lur_update_rec));
179 }
180
181 static inline struct update_op *
182 update_ops_get_op(const struct update_ops *ops, unsigned int index,
183                   unsigned int update_count)
184 {
185         struct update_op *op;
186         unsigned int i;
187
188         if (index > update_count)
189                 return NULL;
190
191         op = (struct update_op *)&ops->uops_op[0];
192         for (i = 0; i < index; i++)
193                 op = update_op_next_op(op);
194
195         return op;
196 }
197
198 static inline void
199 *object_update_param_get(const struct object_update *update, size_t index,
200                          size_t *size)
201 {
202         const struct    object_update_param *param;
203         size_t          i;
204
205         if (index >= update->ou_params_count)
206                 return ERR_PTR(-EINVAL);
207
208         param = &update->ou_params[0];
209         for (i = 0; i < index; i++)
210                 param = (struct object_update_param *)((char *)param +
211                         object_update_param_size(param));
212
213         if (size != NULL)
214                 *size = param->oup_len;
215
216         if (param->oup_len == 0)
217                 return ERR_PTR(-ENODATA);
218
219         return (void *)&param->oup_buf[0];
220 }
221
222 static inline unsigned long
223 object_update_request_size(const struct object_update_request *our)
224 {
225         unsigned long   size;
226         size_t          i = 0;
227
228         size = offsetof(struct object_update_request, ourq_updates[0]);
229         for (i = 0; i < our->ourq_count; i++) {
230                 struct object_update *update;
231
232                 update = (struct object_update *)((char *)our + size);
233                 size += object_update_size(update);
234         }
235         return size;
236 }
237
238 static inline void
239 object_update_result_insert(struct object_update_reply *reply,
240                             void *data, size_t data_len, size_t index,
241                             int rc)
242 {
243         struct object_update_result *update_result;
244         char *ptr;
245
246         update_result = object_update_result_get(reply, index, NULL);
247         LASSERT(update_result);
248
249         update_result->our_rc = ptlrpc_status_hton(rc);
250         if (rc >= 0) {
251                 if (data_len > 0) {
252                         LASSERT(data);
253
254                         ptr = (char *)update_result +
255                         cfs_size_round(sizeof(struct object_update_reply));
256                         memcpy(ptr, data, data_len);
257                 }
258                 update_result->our_datalen = data_len;
259         }
260
261         reply->ourp_lens[index] = cfs_size_round(data_len +
262                                         sizeof(struct object_update_result));
263 }
264
265 static inline int
266 object_update_result_data_get(const struct object_update_reply *reply,
267                               struct lu_buf *lbuf, size_t index)
268 {
269         struct object_update_result *update_result;
270         size_t size = 0;
271         int    result;
272
273         LASSERT(lbuf != NULL);
274         update_result = object_update_result_get(reply, index, &size);
275         if (update_result == NULL ||
276             size < cfs_size_round(sizeof(struct object_update_reply)) ||
277             update_result->our_datalen > size)
278                 RETURN(-EFAULT);
279
280         result = ptlrpc_status_ntoh(update_result->our_rc);
281         if (result < 0)
282                 return result;
283
284         lbuf->lb_buf = update_result->our_data;
285         lbuf->lb_len = update_result->our_datalen;
286
287         return result;
288 }
289
290 /**
291  * Attached in the thandle to record the updates for distribute
292  * distribution.
293  */
294 struct thandle_update_records {
295         /* All of updates for the cross-MDT operation, vmalloc'd. */
296         struct llog_update_record       *tur_update_records;
297         size_t                          tur_update_records_buf_size;
298
299         /* All of parameters for the cross-MDT operation, vmalloc'd */
300         struct update_params    *tur_update_params;
301         unsigned int            tur_update_param_count;
302         size_t                  tur_update_params_buf_size;
303 };
304
305 #define TOP_THANDLE_MAGIC       0x20140917
306 struct top_multiple_thandle {
307         struct dt_device        *tmt_master_sub_dt;
308         atomic_t                tmt_refcount;
309         /* Other sub transactions will be listed here. */
310         struct list_head        tmt_sub_thandle_list;
311         spinlock_t              tmt_sub_lock;
312
313         struct list_head        tmt_commit_list;
314         /* All of update records will packed here */
315         struct thandle_update_records *tmt_update_records;
316
317         wait_queue_head_t       tmt_stop_waitq;
318         __u64                   tmt_batchid;
319         int                     tmt_result;
320         __u32                   tmt_magic;
321         size_t                  tmt_record_size;
322         __u32                   tmt_committed:1;
323 };
324
325 /* {top,sub}_thandle are used to manage distributed transactions which
326  * include updates on several nodes. A top_handle represents the
327  * whole operation, and sub_thandle represents updates on each node. */
328 struct top_thandle {
329         struct thandle          tt_super;
330         /* The master sub transaction. */
331         struct thandle          *tt_master_sub_thandle;
332
333         struct top_multiple_thandle *tt_multiple_thandle;
334 };
335
336 struct sub_thandle_cookie {
337         struct llog_cookie      stc_cookie;
338         struct list_head        stc_list;
339 };
340
341 /* Sub thandle is used to track multiple sub thandles under one parent
342  * thandle */
343 struct sub_thandle {
344         struct thandle          *st_sub_th;
345         struct dt_device        *st_dt;
346         struct list_head        st_cookie_list;
347         struct dt_txn_commit_cb st_commit_dcb;
348         struct dt_txn_commit_cb st_stop_dcb;
349         int                     st_result;
350
351         /* linked to top_thandle */
352         struct list_head        st_sub_list;
353
354         /* If this sub thandle is committed */
355         bool                    st_committed:1,
356                                 st_stopped:1,
357                                 st_started:1;
358 };
359
360 struct tx_arg;
361 typedef int (*tx_exec_func_t)(const struct lu_env *env, struct thandle *th,
362                               struct tx_arg *ta);
363
364 /* Structure for holding one update execution */
365 struct tx_arg {
366         tx_exec_func_t           exec_fn;
367         tx_exec_func_t           undo_fn;
368         struct dt_object        *object;
369         const char              *file;
370         struct object_update_reply *reply;
371         int                      line;
372         int                      index;
373         union {
374                 struct {
375                         struct dt_insert_rec     rec;
376                         const struct dt_key     *key;
377                 } insert;
378                 struct {
379                 } ref;
380                 struct {
381                         struct lu_attr   attr;
382                 } attr_set;
383                 struct {
384                         struct lu_buf    buf;
385                         const char      *name;
386                         int              flags;
387                         __u32            csum;
388                 } xattr_set;
389                 struct {
390                         struct lu_attr                  attr;
391                         struct dt_allocation_hint       hint;
392                         struct dt_object_format         dof;
393                         struct lu_fid                   fid;
394                 } create;
395                 struct {
396                         struct lu_buf   buf;
397                         loff_t          pos;
398                 } write;
399                 struct {
400                         struct ost_body     *body;
401                 } destroy;
402         } u;
403 };
404
405 /* Structure for holding all update executations of one transaction */
406 struct thandle_exec_args {
407         struct thandle          *ta_handle;
408         int                     ta_argno;   /* used args */
409         int                     ta_alloc_args; /* allocated args count */
410         struct tx_arg           **ta_args;
411 };
412
413 /* target/out_lib.c */
414 int out_update_pack(const struct lu_env *env, struct object_update *update,
415                     size_t *max_update_size, enum update_type op,
416                     const struct lu_fid *fid, unsigned int params_count,
417                     __u16 *param_sizes, const void **param_bufs,
418                     __u32 reply_size);
419 int out_create_pack(const struct lu_env *env, struct object_update *update,
420                     size_t *max_update_size, const struct lu_fid *fid,
421                     const struct lu_attr *attr, struct dt_allocation_hint *hint,
422                     struct dt_object_format *dof);
423 int out_destroy_pack(const struct lu_env *env, struct object_update *update,
424                      size_t *max_update_size, 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_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_destroy_pack(const struct lu_env *env,
581                                 struct update_ops *ops, unsigned int *op_count,
582                                 size_t *max_ops_size,
583                                 struct update_params *params,
584                                 unsigned int *param_count,
585                                 size_t *max_param_size,
586                                 const struct lu_fid *fid);
587 int update_records_index_insert_pack(const struct lu_env *env,
588                                      struct update_ops *ops,
589                                      unsigned int *op_count,
590                                      size_t *max_ops_size,
591                                      struct update_params *params,
592                                      unsigned int *param_count,
593                                      size_t *max_param_size,
594                                      const struct lu_fid *fid,
595                                      const struct dt_rec *rec,
596                                      const struct dt_key *key);
597 int update_records_index_delete_pack(const struct lu_env *env,
598                                      struct update_ops *ops,
599                                      unsigned int *op_count,
600                                      size_t *max_ops_size,
601                                      struct update_params *params,
602                                      unsigned int *param_count,
603                                      size_t *max_param_size,
604                                      const struct lu_fid *fid,
605                                      const struct dt_key *key);
606 int update_records_xattr_set_pack(const struct lu_env *env,
607                                   struct update_ops *ops,
608                                   unsigned int *op_count,
609                                   size_t *max_ops_size,
610                                   struct update_params *params,
611                                   unsigned int *param_count,
612                                   size_t *max_param_size,
613                                   const struct lu_fid *fid,
614                                   const struct lu_buf *buf, const char *name,
615                                   __u32 flag);
616 int update_records_xattr_del_pack(const struct lu_env *env,
617                                   struct update_ops *ops,
618                                   unsigned int *op_count,
619                                   size_t *max_ops_size,
620                                   struct update_params *params,
621                                   unsigned int *param_count,
622                                   size_t *max_param_size,
623                                   const struct lu_fid *fid,
624                                   const char *name);
625 int update_records_write_pack(const struct lu_env *env,
626                               struct update_ops *ops,
627                               unsigned int *op_count,
628                               size_t *max_ops_size,
629                               struct update_params *params,
630                               unsigned int *param_count,
631                               size_t *max_param_size,
632                               const struct lu_fid *fid,
633                               const struct lu_buf *buf,
634                               __u64 pos);
635 int update_records_punch_pack(const struct lu_env *env,
636                               struct update_ops *ops,
637                               unsigned int *op_count,
638                               size_t *max_ops_size,
639                               struct update_params *params,
640                               unsigned int *param_count,
641                               size_t *max_param_size,
642                               const struct lu_fid *fid,
643                               __u64 start, __u64 end);
644 int update_records_noop_pack(const struct lu_env *env,
645                              struct update_ops *ops,
646                              unsigned int *op_count,
647                              size_t *max_ops_size,
648                              struct update_params *params,
649                              unsigned int *param_count,
650                              size_t *max_param_size,
651                              const struct lu_fid *fid);
652
653 int tur_update_records_extend(struct thandle_update_records *tur,
654                               size_t new_size);
655 int tur_update_params_extend(struct thandle_update_records *tur,
656                              size_t new_size);
657 int tur_update_extend(struct thandle_update_records *tur,
658                       size_t new_op_size, size_t new_param_size);
659
660 #define update_record_pack(name, th, ...)                               \
661 ({                                                                      \
662         struct top_thandle *top_th;                                     \
663         struct top_multiple_thandle *tmt;                               \
664         struct thandle_update_records *tur;                             \
665         struct llog_update_record     *lur;                             \
666         size_t          avail_param_size;                               \
667         size_t          avail_op_size;                                  \
668         int             ret;                                            \
669                                                                         \
670         while (1) {                                                     \
671                 top_th = container_of(th, struct top_thandle, tt_super);\
672                 tmt = top_th->tt_multiple_thandle;                      \
673                 tur = tmt->tmt_update_records;                          \
674                 lur = tur->tur_update_records;                          \
675                 avail_param_size = tur->tur_update_params_buf_size -    \
676                              update_params_size(tur->tur_update_params, \
677                                         tur->tur_update_param_count);   \
678                 avail_op_size = tur->tur_update_records_buf_size -      \
679                                 llog_update_record_size(lur);           \
680                 ret = update_records_##name##_pack(env,                 \
681                                           &lur->lur_update_rec.ur_ops,  \
682                                   &lur->lur_update_rec.ur_update_count, \
683                                   &avail_op_size,                       \
684                                   tur->tur_update_params,               \
685                                   &tur->tur_update_param_count,         \
686                                   &avail_param_size, __VA_ARGS__);      \
687                 if (ret == -E2BIG) {                                    \
688                         ret = tur_update_extend(tur, avail_op_size,     \
689                                                    avail_param_size);   \
690                         if (ret != 0)                                   \
691                                 break;                                  \
692                         continue;                                       \
693                 } else {                                                \
694                         break;                                          \
695                 }                                                       \
696         }                                                               \
697         ret;                                                            \
698 })
699
700 #define update_record_size(env, name, th, ...)                          \
701 ({                                                                      \
702         struct top_thandle *top_th;                                     \
703         struct top_multiple_thandle *tmt;                               \
704                                                                         \
705         top_th = container_of(th, struct top_thandle, tt_super);        \
706                                                                         \
707         LASSERT(top_th->tt_multiple_thandle != NULL);                   \
708         tmt = top_th->tt_multiple_thandle;                              \
709         tmt->tmt_record_size +=                                         \
710                 update_records_##name##_size(env, __VA_ARGS__);         \
711 })
712 #endif