2 * Copyright (C) 2005, 2006
3 * Avishay Traeger (avishay@gmail.com)
4 * Copyright (C) 2008, 2009
5 * Boaz Harrosh <bharrosh@panasas.com>
7 * This file is part of exofs.
9 * exofs is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation. Since it is based on ext2, and the only
12 * valid version of GPL for the Linux kernel is version 2, the only valid
13 * version of GPL for exofs is version 2.
15 * exofs is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with exofs; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <linux/slab.h>
26 #include <asm/div64.h>
28 #include <scsi/osd_ore.h>
30 #define ORE_ERR(fmt, a...) printk(KERN_ERR "ore: " fmt, ##a)
32 #ifdef CONFIG_EXOFS_DEBUG
33 #define ORE_DBGMSG(fmt, a...) \
34 printk(KERN_NOTICE "ore @%s:%d: " fmt, __func__, __LINE__, ##a)
36 #define ORE_DBGMSG(fmt, a...) \
37 do { if (0) printk(fmt, ##a); } while (0)
40 /* u64 has problems with printk this will cast it to unsigned long long */
41 #define _LLU(x) (unsigned long long)(x)
43 #define ORE_DBGMSG2(M...) do {} while (0)
44 /* #define ORE_DBGMSG2 ORE_DBGMSG */
46 MODULE_AUTHOR("Boaz Harrosh <bharrosh@panasas.com>");
47 MODULE_DESCRIPTION("Objects Raid Engine ore.ko");
48 MODULE_LICENSE("GPL");
50 /* ore_verify_layout does a couple of things:
51 * 1. Given a minimum number of needed parameters fixes up the rest of the
52 * members to be operatonals for the ore. The needed parameters are those
53 * that are defined by the pnfs-objects layout STD.
54 * 2. Check to see if the current ore code actually supports these parameters
55 * for example stripe_unit must be a multple of the system PAGE_SIZE,
57 * 3. Cache some havily used calculations that will be needed by users.
60 static void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset,
61 struct ore_striping_info *si);
63 enum { BIO_MAX_PAGES_KMALLOC =
64 (PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec),};
66 int ore_verify_layout(unsigned total_comps, struct ore_layout *layout)
70 /* FIXME: Only raid0 is supported for now. */
71 if (layout->raid_algorithm != PNFS_OSD_RAID_0) {
72 ORE_ERR("Only RAID_0 for now\n");
75 if (0 != (layout->stripe_unit & ~PAGE_MASK)) {
76 ORE_ERR("Stripe Unit(0x%llx)"
77 " must be Multples of PAGE_SIZE(0x%lx)\n",
78 _LLU(layout->stripe_unit), PAGE_SIZE);
81 if (layout->group_width) {
82 if (!layout->group_depth) {
83 ORE_ERR("group_depth == 0 && group_width != 0\n");
86 if (total_comps < (layout->group_width * layout->mirrors_p1)) {
87 ORE_ERR("Data Map wrong, "
88 "numdevs=%d < group_width=%d * mirrors=%d\n",
89 total_comps, layout->group_width,
93 layout->group_count = total_comps / layout->mirrors_p1 /
96 if (layout->group_depth) {
97 printk(KERN_NOTICE "Warning: group_depth ignored "
98 "group_width == 0 && group_depth == %lld\n",
99 _LLU(layout->group_depth));
101 layout->group_width = total_comps / layout->mirrors_p1;
102 layout->group_depth = -1;
103 layout->group_count = 1;
106 stripe_length = (u64)layout->group_width * layout->stripe_unit;
107 if (stripe_length >= (1ULL << 32)) {
108 ORE_ERR("Stripe_length(0x%llx) >= 32bit is not supported\n",
109 _LLU(stripe_length));
113 layout->max_io_length =
114 (BIO_MAX_PAGES_KMALLOC * PAGE_SIZE - layout->stripe_unit) *
118 EXPORT_SYMBOL(ore_verify_layout);
120 static u8 *_ios_cred(struct ore_io_state *ios, unsigned index)
122 return ios->oc->comps[index & ios->oc->single_comp].cred;
125 static struct osd_obj_id *_ios_obj(struct ore_io_state *ios, unsigned index)
127 return &ios->oc->comps[index & ios->oc->single_comp].obj;
130 static struct osd_dev *_ios_od(struct ore_io_state *ios, unsigned index)
132 ORE_DBGMSG2("oc->first_dev=%d oc->numdevs=%d i=%d oc->ods=%p\n",
133 ios->oc->first_dev, ios->oc->numdevs, index,
136 return ore_comp_dev(ios->oc, index);
139 static int _get_io_state(struct ore_layout *layout,
140 struct ore_components *oc, unsigned numdevs,
141 struct ore_io_state **pios)
143 struct ore_io_state *ios;
145 /*TODO: Maybe use kmem_cach per sbi of size
146 * exofs_io_state_size(layout->s_numdevs)
148 ios = kzalloc(ore_io_state_size(numdevs), GFP_KERNEL);
149 if (unlikely(!ios)) {
150 ORE_DBGMSG("Failed kzalloc bytes=%d\n",
151 ore_io_state_size(numdevs));
156 ios->layout = layout;
162 /* Allocate an io_state for only a single group of devices
164 * If a user needs to call ore_read/write() this version must be used becase it
165 * allocates extra stuff for striping and raid.
166 * The ore might decide to only IO less then @length bytes do to alignmets
167 * and constrains as follows:
168 * - The IO cannot cross group boundary.
169 * - In raid5/6 The end of the IO must align at end of a stripe eg.
170 * (@offset + @length) % strip_size == 0. Or the complete range is within a
172 * - Memory condition only permitted a shorter IO. (A user can use @length=~0
173 * And check the returned ios->length for max_io_size.)
175 * The caller must check returned ios->length (and/or ios->nr_pages) and
176 * re-issue these pages that fall outside of ios->length
178 int ore_get_rw_state(struct ore_layout *layout, struct ore_components *oc,
179 bool is_reading, u64 offset, u64 length,
180 struct ore_io_state **pios)
182 struct ore_io_state *ios;
183 unsigned numdevs = layout->group_width * layout->mirrors_p1;
186 ret = _get_io_state(layout, oc, numdevs, pios);
191 ios->reading = is_reading;
192 ios->offset = offset;
195 ore_calc_stripe_info(layout, offset, &ios->si);
196 ios->length = (length <= ios->si.group_length) ? length :
197 ios->si.group_length;
198 ios->nr_pages = (ios->length + PAGE_SIZE - 1) / PAGE_SIZE;
203 EXPORT_SYMBOL(ore_get_rw_state);
205 /* Allocate an io_state for all the devices in the comps array
207 * This version of io_state allocation is used mostly by create/remove
208 * and trunc where we currently need all the devices. The only wastful
209 * bit is the read/write_attributes with no IO. Those sites should
210 * be converted to use ore_get_rw_state() with length=0
212 int ore_get_io_state(struct ore_layout *layout, struct ore_components *oc,
213 struct ore_io_state **pios)
215 return _get_io_state(layout, oc, oc->numdevs, pios);
217 EXPORT_SYMBOL(ore_get_io_state);
219 void ore_put_io_state(struct ore_io_state *ios)
224 for (i = 0; i < ios->numdevs; i++) {
225 struct ore_per_dev_state *per_dev = &ios->per_dev[i];
228 osd_end_request(per_dev->or);
230 bio_put(per_dev->bio);
236 EXPORT_SYMBOL(ore_put_io_state);
238 static void _sync_done(struct ore_io_state *ios, void *p)
240 struct completion *waiting = p;
245 static void _last_io(struct kref *kref)
247 struct ore_io_state *ios = container_of(
248 kref, struct ore_io_state, kref);
250 ios->done(ios, ios->private);
253 static void _done_io(struct osd_request *or, void *p)
255 struct ore_io_state *ios = p;
257 kref_put(&ios->kref, _last_io);
260 static int ore_io_execute(struct ore_io_state *ios)
262 DECLARE_COMPLETION_ONSTACK(wait);
263 bool sync = (ios->done == NULL);
267 ios->done = _sync_done;
268 ios->private = &wait;
271 for (i = 0; i < ios->numdevs; i++) {
272 struct osd_request *or = ios->per_dev[i].or;
276 ret = osd_finalize_request(or, 0, _ios_cred(ios, i), NULL);
278 ORE_DBGMSG("Failed to osd_finalize_request() => %d\n",
284 kref_init(&ios->kref);
286 for (i = 0; i < ios->numdevs; i++) {
287 struct osd_request *or = ios->per_dev[i].or;
291 kref_get(&ios->kref);
292 osd_execute_request_async(or, _done_io, ios);
295 kref_put(&ios->kref, _last_io);
299 wait_for_completion(&wait);
300 ret = ore_check_io(ios, NULL);
305 static void _clear_bio(struct bio *bio)
310 __bio_for_each_segment(bv, bio, i, 0) {
311 unsigned this_count = bv->bv_len;
313 if (likely(PAGE_SIZE == this_count))
314 clear_highpage(bv->bv_page);
316 zero_user(bv->bv_page, bv->bv_offset, this_count);
320 int ore_check_io(struct ore_io_state *ios, u64 *resid)
322 enum osd_err_priority acumulated_osd_err = 0;
323 int acumulated_lin_err = 0;
326 for (i = 0; i < ios->numdevs; i++) {
327 struct osd_sense_info osi;
328 struct osd_request *or = ios->per_dev[i].or;
334 ret = osd_req_decode_sense(or, &osi);
338 if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) {
339 /* start read offset passed endof file */
340 _clear_bio(ios->per_dev[i].bio);
341 ORE_DBGMSG("start read offset passed end of file "
342 "offset=0x%llx, length=0x%llx\n",
343 _LLU(ios->per_dev[i].offset),
344 _LLU(ios->per_dev[i].length));
346 continue; /* we recovered */
349 if (osi.osd_err_pri >= acumulated_osd_err) {
350 acumulated_osd_err = osi.osd_err_pri;
351 acumulated_lin_err = ret;
355 /* TODO: raid specific residual calculations */
357 if (likely(!acumulated_lin_err))
360 *resid = ios->length;
363 return acumulated_lin_err;
365 EXPORT_SYMBOL(ore_check_io);
368 * L - logical offset into the file
370 * U - The number of bytes in a stripe within a group
372 * U = stripe_unit * group_width
374 * T - The number of bytes striped within a group of component objects
375 * (before advancing to the next group)
377 * T = stripe_unit * group_width * group_depth
379 * S - The number of bytes striped across all component objects
380 * before the pattern repeats
382 * S = stripe_unit * group_width * group_depth * group_count
384 * M - The "major" (i.e., across all components) stripe number
388 * G - Counts the groups from the beginning of the major stripe
390 * G = (L - (M * S)) / T [or (L % S) / T]
392 * H - The byte offset within the group
394 * H = (L - (M * S)) % T [or (L % S) % T]
396 * N - The "minor" (i.e., across the group) stripe number
400 * C - The component index coresponding to L
402 * C = (H - (N * U)) / stripe_unit + G * group_width
403 * [or (L % U) / stripe_unit + G * group_width]
405 * O - The component offset coresponding to L
407 * O = L % stripe_unit + N * stripe_unit + M * group_depth * stripe_unit
409 static void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset,
410 struct ore_striping_info *si)
412 u32 stripe_unit = layout->stripe_unit;
413 u32 group_width = layout->group_width;
414 u64 group_depth = layout->group_depth;
416 u32 U = stripe_unit * group_width;
417 u64 T = U * group_depth;
418 u64 S = T * layout->group_count;
419 u64 M = div64_u64(file_offset, S);
422 G = (L - (M * S)) / T
423 H = (L - (M * S)) % T
425 u64 LmodS = file_offset - M * S;
426 u32 G = div64_u64(LmodS, T);
427 u64 H = LmodS - G * T;
429 u32 N = div_u64(H, U);
431 /* "H - (N * U)" is just "H % U" so it's bound to u32 */
432 si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width;
433 si->dev *= layout->mirrors_p1;
435 div_u64_rem(file_offset, stripe_unit, &si->unit_off);
437 si->obj_offset = si->unit_off + (N * stripe_unit) +
438 (M * group_depth * stripe_unit);
440 si->group_length = T - H;
444 static int _add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg,
445 unsigned pgbase, struct ore_per_dev_state *per_dev,
448 unsigned pg = *cur_pg;
449 struct request_queue *q =
450 osd_request_queue(_ios_od(ios, per_dev->dev));
451 unsigned len = cur_len;
454 if (per_dev->bio == NULL) {
455 unsigned pages_in_stripe = ios->layout->group_width *
456 (ios->layout->stripe_unit / PAGE_SIZE);
457 unsigned bio_size = (ios->nr_pages + pages_in_stripe) /
458 ios->layout->group_width;
460 per_dev->bio = bio_kmalloc(GFP_KERNEL, bio_size);
461 if (unlikely(!per_dev->bio)) {
462 ORE_DBGMSG("Failed to allocate BIO size=%u\n",
469 while (cur_len > 0) {
470 unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len);
473 BUG_ON(ios->nr_pages <= pg);
476 added_len = bio_add_pc_page(q, per_dev->bio, ios->pages[pg],
478 if (unlikely(pglen != added_len)) {
487 per_dev->length += len;
490 out: /* we fail the complete unit on an error eg don't advance
491 * per_dev->length and cur_pg. This means that we might have a bigger
492 * bio than the CDB requested length (per_dev->length). That's fine
493 * only the oposite is fatal.
498 static int _prepare_for_striping(struct ore_io_state *ios)
500 struct ore_striping_info *si = &ios->si;
501 unsigned stripe_unit = ios->layout->stripe_unit;
502 unsigned mirrors_p1 = ios->layout->mirrors_p1;
503 unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
504 unsigned dev = si->dev;
505 unsigned first_dev = dev - (dev % devs_in_group);
506 unsigned cur_pg = ios->pages_consumed;
507 u64 length = ios->length;
511 ios->numdevs = ios->layout->mirrors_p1;
515 BUG_ON(length > si->group_length);
518 unsigned comp = dev - first_dev;
519 struct ore_per_dev_state *per_dev = &ios->per_dev[comp];
520 unsigned cur_len, page_off = 0;
522 if (!per_dev->length) {
525 per_dev->offset = si->obj_offset + stripe_unit -
527 cur_len = stripe_unit;
528 } else if (dev == si->dev) {
529 per_dev->offset = si->obj_offset;
530 cur_len = stripe_unit - si->unit_off;
531 page_off = si->unit_off & ~PAGE_MASK;
532 BUG_ON(page_off && (page_off != ios->pgbase));
533 } else { /* dev > si->dev */
534 per_dev->offset = si->obj_offset - si->unit_off;
535 cur_len = stripe_unit;
538 cur_len = stripe_unit;
540 if (cur_len >= length)
543 ret = _add_stripe_unit(ios, &cur_pg, page_off , per_dev,
549 dev = (dev % devs_in_group) + first_dev;
554 ios->numdevs = devs_in_group;
555 ios->pages_consumed = cur_pg;
557 if (length == ios->length)
560 ios->length -= length;
565 int ore_create(struct ore_io_state *ios)
569 for (i = 0; i < ios->oc->numdevs; i++) {
570 struct osd_request *or;
572 or = osd_start_request(_ios_od(ios, i), GFP_KERNEL);
574 ORE_ERR("%s: osd_start_request failed\n", __func__);
578 ios->per_dev[i].or = or;
581 osd_req_create_object(or, _ios_obj(ios, i));
583 ret = ore_io_execute(ios);
588 EXPORT_SYMBOL(ore_create);
590 int ore_remove(struct ore_io_state *ios)
594 for (i = 0; i < ios->oc->numdevs; i++) {
595 struct osd_request *or;
597 or = osd_start_request(_ios_od(ios, i), GFP_KERNEL);
599 ORE_ERR("%s: osd_start_request failed\n", __func__);
603 ios->per_dev[i].or = or;
606 osd_req_remove_object(or, _ios_obj(ios, i));
608 ret = ore_io_execute(ios);
613 EXPORT_SYMBOL(ore_remove);
615 static int _write_mirror(struct ore_io_state *ios, int cur_comp)
617 struct ore_per_dev_state *master_dev = &ios->per_dev[cur_comp];
618 unsigned dev = ios->per_dev[cur_comp].dev;
619 unsigned last_comp = cur_comp + ios->layout->mirrors_p1;
622 if (ios->pages && !master_dev->length)
623 return 0; /* Just an empty slot */
625 for (; cur_comp < last_comp; ++cur_comp, ++dev) {
626 struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp];
627 struct osd_request *or;
629 or = osd_start_request(_ios_od(ios, dev), GFP_KERNEL);
631 ORE_ERR("%s: osd_start_request failed\n", __func__);
640 if (per_dev != master_dev) {
641 bio = bio_kmalloc(GFP_KERNEL,
642 master_dev->bio->bi_max_vecs);
643 if (unlikely(!bio)) {
645 "Failed to allocate BIO size=%u\n",
646 master_dev->bio->bi_max_vecs);
651 __bio_clone(bio, master_dev->bio);
654 per_dev->offset = master_dev->offset;
655 per_dev->length = master_dev->length;
659 bio = master_dev->bio;
660 /* FIXME: bio_set_dir() */
661 bio->bi_rw |= REQ_WRITE;
664 osd_req_write(or, _ios_obj(ios, dev), per_dev->offset,
665 bio, per_dev->length);
666 ORE_DBGMSG("write(0x%llx) offset=0x%llx "
667 "length=0x%llx dev=%d\n",
668 _LLU(_ios_obj(ios, dev)->id),
669 _LLU(per_dev->offset),
670 _LLU(per_dev->length), dev);
671 } else if (ios->kern_buff) {
672 per_dev->offset = ios->si.obj_offset;
673 per_dev->dev = ios->si.dev + dev;
675 /* no cross device without page array */
676 BUG_ON((ios->layout->group_width > 1) &&
677 (ios->si.unit_off + ios->length >
678 ios->layout->stripe_unit));
680 ret = osd_req_write_kern(or, _ios_obj(ios, per_dev->dev),
682 ios->kern_buff, ios->length);
685 ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx "
686 "length=0x%llx dev=%d\n",
687 _LLU(_ios_obj(ios, dev)->id),
688 _LLU(per_dev->offset),
689 _LLU(ios->length), per_dev->dev);
691 osd_req_set_attributes(or, _ios_obj(ios, dev));
692 ORE_DBGMSG2("obj(0x%llx) set_attributes=%d dev=%d\n",
693 _LLU(_ios_obj(ios, dev)->id),
694 ios->out_attr_len, dev);
698 osd_req_add_set_attr_list(or, ios->out_attr,
702 osd_req_add_get_attr_list(or, ios->in_attr,
710 int ore_write(struct ore_io_state *ios)
715 ret = _prepare_for_striping(ios);
719 for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) {
720 ret = _write_mirror(ios, i);
725 ret = ore_io_execute(ios);
728 EXPORT_SYMBOL(ore_write);
730 static int _read_mirror(struct ore_io_state *ios, unsigned cur_comp)
732 struct osd_request *or;
733 struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp];
734 struct osd_obj_id *obj = _ios_obj(ios, cur_comp);
735 unsigned first_dev = (unsigned)obj->id;
737 if (ios->pages && !per_dev->length)
738 return 0; /* Just an empty slot */
740 first_dev = per_dev->dev + first_dev % ios->layout->mirrors_p1;
741 or = osd_start_request(_ios_od(ios, first_dev), GFP_KERNEL);
743 ORE_ERR("%s: osd_start_request failed\n", __func__);
749 osd_req_read(or, obj, per_dev->offset,
750 per_dev->bio, per_dev->length);
751 ORE_DBGMSG("read(0x%llx) offset=0x%llx length=0x%llx"
752 " dev=%d\n", _LLU(obj->id),
753 _LLU(per_dev->offset), _LLU(per_dev->length),
756 BUG_ON(ios->kern_buff);
758 osd_req_get_attributes(or, obj);
759 ORE_DBGMSG2("obj(0x%llx) get_attributes=%d dev=%d\n",
761 ios->in_attr_len, first_dev);
764 osd_req_add_set_attr_list(or, ios->out_attr, ios->out_attr_len);
767 osd_req_add_get_attr_list(or, ios->in_attr, ios->in_attr_len);
772 int ore_read(struct ore_io_state *ios)
777 ret = _prepare_for_striping(ios);
781 for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) {
782 ret = _read_mirror(ios, i);
787 ret = ore_io_execute(ios);
790 EXPORT_SYMBOL(ore_read);
792 int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr)
794 struct osd_attr cur_attr = {.attr_page = 0}; /* start with zeros */
800 osd_req_decode_get_attr_list(ios->per_dev[0].or,
801 &cur_attr, &nelem, &iter);
802 if ((cur_attr.attr_page == attr->attr_page) &&
803 (cur_attr.attr_id == attr->attr_id)) {
804 attr->len = cur_attr.len;
805 attr->val_ptr = cur_attr.val_ptr;
812 EXPORT_SYMBOL(extract_attr_from_ios);
814 static int _truncate_mirrors(struct ore_io_state *ios, unsigned cur_comp,
815 struct osd_attr *attr)
817 int last_comp = cur_comp + ios->layout->mirrors_p1;
819 for (; cur_comp < last_comp; ++cur_comp) {
820 struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp];
821 struct osd_request *or;
823 or = osd_start_request(_ios_od(ios, cur_comp), GFP_KERNEL);
825 ORE_ERR("%s: osd_start_request failed\n", __func__);
830 osd_req_set_attributes(or, _ios_obj(ios, cur_comp));
831 osd_req_add_set_attr_list(or, attr, 1);
838 struct ore_striping_info si;
839 u64 prev_group_obj_off;
840 u64 next_group_obj_off;
842 unsigned first_group_dev;
843 unsigned nex_group_dev;
846 static void _calc_trunk_info(struct ore_layout *layout, u64 file_offset,
847 struct _trunc_info *ti)
849 unsigned stripe_unit = layout->stripe_unit;
851 ore_calc_stripe_info(layout, file_offset, &ti->si);
853 ti->prev_group_obj_off = ti->si.M * stripe_unit;
854 ti->next_group_obj_off = ti->si.M ? (ti->si.M - 1) * stripe_unit : 0;
856 ti->first_group_dev = ti->si.dev - (ti->si.dev % layout->group_width);
857 ti->nex_group_dev = ti->first_group_dev + layout->group_width;
860 int ore_truncate(struct ore_layout *layout, struct ore_components *oc,
863 struct ore_io_state *ios;
864 struct exofs_trunc_attr {
865 struct osd_attr attr;
868 struct _trunc_info ti;
871 ret = ore_get_io_state(layout, oc, &ios);
875 _calc_trunk_info(ios->layout, size, &ti);
877 size_attrs = kcalloc(ios->oc->numdevs, sizeof(*size_attrs),
879 if (unlikely(!size_attrs)) {
884 ios->numdevs = ios->oc->numdevs;
886 for (i = 0; i < ios->numdevs; ++i) {
887 struct exofs_trunc_attr *size_attr = &size_attrs[i];
890 if (i < ti.first_group_dev)
891 obj_size = ti.prev_group_obj_off;
892 else if (i >= ti.nex_group_dev)
893 obj_size = ti.next_group_obj_off;
894 else if (i < ti.si.dev) /* dev within this group */
895 obj_size = ti.si.obj_offset +
896 ios->layout->stripe_unit - ti.si.unit_off;
897 else if (i == ti.si.dev)
898 obj_size = ti.si.obj_offset;
899 else /* i > ti.dev */
900 obj_size = ti.si.obj_offset - ti.si.unit_off;
902 size_attr->newsize = cpu_to_be64(obj_size);
903 size_attr->attr = g_attr_logical_length;
904 size_attr->attr.val_ptr = &size_attr->newsize;
906 ORE_DBGMSG("trunc(0x%llx) obj_offset=0x%llx dev=%d\n",
907 _LLU(oc->comps->obj.id), _LLU(obj_size), i);
908 ret = _truncate_mirrors(ios, i * ios->layout->mirrors_p1,
913 ret = ore_io_execute(ios);
917 ore_put_io_state(ios);
920 EXPORT_SYMBOL(ore_truncate);
922 const struct osd_attr g_attr_logical_length = ATTR_DEF(
923 OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
924 EXPORT_SYMBOL(g_attr_logical_length);