4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, 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).
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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * Copyright (c) 2012, 2013, Intel Corporation.
32 * Use is subject to license terms.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
38 * lustre/osd-zfs/osd_io.c
40 * Author: Alex Zhuravlev <bzzz@whamcloud.com>
41 * Author: Mike Pershin <tappro@whamcloud.com>
44 #define DEBUG_SUBSYSTEM S_OSD
46 #include <lustre_ver.h>
47 #include <libcfs/libcfs.h>
48 #include <obd_support.h>
49 #include <lustre_net.h>
51 #include <obd_class.h>
52 #include <lustre_disk.h>
53 #include <lustre_fid.h>
54 #include <lustre/lustre_idl.h> /* LLOG_CHUNK_SIZE definition */
56 #include "osd_internal.h"
58 #include <sys/dnode.h>
63 #include <sys/spa_impl.h>
64 #include <sys/zfs_znode.h>
65 #include <sys/dmu_tx.h>
66 #include <sys/dmu_objset.h>
67 #include <sys/dsl_prop.h>
68 #include <sys/sa_impl.h>
71 static char *osd_zerocopy_tag = "zerocopy";
73 static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt,
74 struct lu_buf *buf, loff_t *pos,
75 struct lustre_capa *capa)
77 struct osd_object *obj = osd_dt_obj(dt);
78 struct osd_device *osd = osd_obj2dev(obj);
80 int size = buf->lb_len;
83 LASSERT(dt_object_exists(dt));
86 read_lock(&obj->oo_attr_lock);
87 old_size = obj->oo_attr.la_size;
88 read_unlock(&obj->oo_attr_lock);
90 if (*pos + size > old_size) {
94 size = old_size - *pos;
97 rc = -dmu_read(osd->od_os, obj->oo_db->db_object, *pos, size,
98 buf->lb_buf, DMU_READ_PREFETCH);
103 /* XXX: workaround for bug in HEAD: fsfilt_ldiskfs_read() returns
104 * requested number of bytes, not actually read ones */
105 if (S_ISLNK(obj->oo_dt.do_lu.lo_header->loh_attr))
111 static ssize_t osd_declare_write(const struct lu_env *env, struct dt_object *dt,
112 const struct lu_buf *buf, loff_t pos,
115 struct osd_object *obj = osd_dt_obj(dt);
116 struct osd_device *osd = osd_obj2dev(obj);
117 struct osd_thandle *oh;
121 oh = container_of0(th, struct osd_thandle, ot_super);
123 /* in some cases declare can race with creation (e.g. llog)
124 * and we need to wait till object is initialized. notice
125 * LOHA_EXISTs is supposed to be the last step in the
128 /* declare possible size change. notice we can't check
129 * current size here as another thread can change it */
131 if (dt_object_exists(dt)) {
133 oid = obj->oo_db->db_object;
135 dmu_tx_hold_sa(oh->ot_tx, obj->oo_sa_hdl, 0);
137 oid = DMU_NEW_OBJECT;
138 dmu_tx_hold_sa_create(oh->ot_tx, ZFS_SA_BASE_ATTR_SIZE);
141 /* XXX: we still miss for append declaration support in ZFS
142 * -1 means append which is used by llog mostly, llog
143 * can grow upto LLOG_CHUNK_SIZE*8 records */
145 pos = max_t(loff_t, 256 * 8 * LLOG_CHUNK_SIZE,
146 obj->oo_attr.la_size + (2 << 20));
147 dmu_tx_hold_write(oh->ot_tx, oid, pos, buf->lb_len);
149 /* dt_declare_write() is usually called for system objects, such
150 * as llog or last_rcvd files. We needn't enforce quota on those
151 * objects, so always set the lqi_space as 0. */
152 RETURN(osd_declare_quota(env, osd, obj->oo_attr.la_uid,
153 obj->oo_attr.la_gid, 0, oh, true, NULL,
157 static ssize_t osd_write(const struct lu_env *env, struct dt_object *dt,
158 const struct lu_buf *buf, loff_t *pos,
159 struct thandle *th, struct lustre_capa *capa,
162 struct osd_object *obj = osd_dt_obj(dt);
163 struct osd_device *osd = osd_obj2dev(obj);
164 struct osd_thandle *oh;
165 uint64_t offset = *pos;
169 LASSERT(dt_object_exists(dt));
173 oh = container_of0(th, struct osd_thandle, ot_super);
175 dmu_write(osd->od_os, obj->oo_db->db_object, offset,
176 (uint64_t)buf->lb_len, buf->lb_buf, oh->ot_tx);
177 write_lock(&obj->oo_attr_lock);
178 if (obj->oo_attr.la_size < offset + buf->lb_len) {
179 obj->oo_attr.la_size = offset + buf->lb_len;
180 write_unlock(&obj->oo_attr_lock);
181 /* osd_object_sa_update() will be copying directly from oo_attr
182 * into dbuf. any update within a single txg will copy the
184 rc = osd_object_sa_update(obj, SA_ZPL_SIZE(osd),
185 &obj->oo_attr.la_size, 8, oh);
189 write_unlock(&obj->oo_attr_lock);
200 * XXX: for the moment I don't want to use lnb_flags for osd-internal
201 * purposes as it's not very well defined ...
202 * instead I use the lowest bit of the address so that:
203 * arc buffer: .lnb_obj = abuf (arc we loan for write)
204 * dbuf buffer: .lnb_obj = dbuf | 1 (dbuf we get for read)
205 * copy buffer: .lnb_page->mapping = obj (page we allocate for write)
209 static int osd_bufs_put(const struct lu_env *env, struct dt_object *dt,
210 struct niobuf_local *lnb, int npages)
212 struct osd_object *obj = osd_dt_obj(dt);
213 struct osd_device *osd = osd_obj2dev(obj);
217 LASSERT(dt_object_exists(dt));
220 for (i = 0; i < npages; i++) {
221 if (lnb[i].lnb_page == NULL)
223 if (lnb[i].lnb_page->mapping == (void *)obj) {
224 /* this is anonymous page allocated for copy-write */
225 lnb[i].lnb_page->mapping = NULL;
226 __free_page(lnb[i].lnb_page);
227 atomic_dec(&osd->od_zerocopy_alloc);
229 /* see comment in osd_bufs_get_read() */
230 ptr = (unsigned long)lnb[i].lnb_data;
233 dmu_buf_rele((void *)ptr, osd_zerocopy_tag);
234 atomic_dec(&osd->od_zerocopy_pin);
235 } else if (lnb[i].lnb_data != NULL) {
236 dmu_return_arcbuf(lnb[i].lnb_data);
237 atomic_dec(&osd->od_zerocopy_loan);
240 lnb[i].lnb_page = NULL;
241 lnb[i].lnb_data = NULL;
247 static inline struct page *kmem_to_page(void *addr)
249 if (is_vmalloc_addr(addr))
250 return vmalloc_to_page(addr);
252 return virt_to_page(addr);
255 static int osd_bufs_get_read(const struct lu_env *env, struct osd_object *obj,
256 loff_t off, ssize_t len, struct niobuf_local *lnb)
258 struct osd_device *osd = osd_obj2dev(obj);
260 int rc, i, numbufs, npages = 0;
263 /* grab buffers for read:
264 * OSD API let us to grab buffers first, then initiate IO(s)
265 * so that all required IOs will be done in parallel, but at the
266 * moment DMU doesn't provide us with a method to grab buffers.
267 * If we discover this is a vital for good performance we
268 * can get own replacement for dmu_buf_hold_array_by_bonus().
271 rc = -dmu_buf_hold_array_by_bonus(obj->oo_db, off, len, TRUE,
272 osd_zerocopy_tag, &numbufs,
277 for (i = 0; i < numbufs; i++) {
278 int bufoff, tocpy, thispage;
283 atomic_inc(&osd->od_zerocopy_pin);
285 bufoff = off - dbp[i]->db_offset;
286 tocpy = min_t(int, dbp[i]->db_size - bufoff, len);
288 /* kind of trick to differentiate dbuf vs. arcbuf */
289 LASSERT(((unsigned long)dbp[i] & 1) == 0);
290 dbf = (void *) ((unsigned long)dbp[i] | 1);
293 thispage = PAGE_CACHE_SIZE;
294 thispage -= bufoff & (PAGE_CACHE_SIZE - 1);
295 thispage = min(tocpy, thispage);
298 lnb->lnb_file_offset = off;
299 lnb->lnb_page_offset = bufoff & ~CFS_PAGE_MASK;
300 lnb->lnb_len = thispage;
301 lnb->lnb_page = kmem_to_page(dbp[i]->db_data +
303 /* mark just a single slot: we need this
304 * reference to dbuf to be release once */
317 /* steal dbuf so dmu_buf_rele_array() cant release it */
321 dmu_buf_rele_array(dbp, numbufs, osd_zerocopy_tag);
328 osd_bufs_put(env, &obj->oo_dt, lnb - npages, npages);
332 static int osd_bufs_get_write(const struct lu_env *env, struct osd_object *obj,
333 loff_t off, ssize_t len, struct niobuf_local *lnb)
335 struct osd_device *osd = osd_obj2dev(obj);
336 int plen, off_in_block, sz_in_block;
337 int rc, i = 0, npages = 0;
343 dmu_object_size_from_db(obj->oo_db, &bs, &dummy);
346 * currently only full blocks are subject to zerocopy approach:
347 * so that we're sure nobody is trying to update the same block
350 LASSERT(npages < PTLRPC_MAX_BRW_PAGES);
352 off_in_block = off & (bs - 1);
353 sz_in_block = min_t(int, bs - off_in_block, len);
355 if (sz_in_block == bs) {
356 /* full block, try to use zerocopy */
358 abuf = dmu_request_arcbuf(obj->oo_db, bs);
359 if (unlikely(abuf == NULL))
360 GOTO(out_err, rc = -ENOMEM);
362 atomic_inc(&osd->od_zerocopy_loan);
364 /* go over pages arcbuf contains, put them as
365 * local niobufs for ptlrpc's bulks */
366 while (sz_in_block > 0) {
367 plen = min_t(int, sz_in_block, PAGE_CACHE_SIZE);
369 lnb[i].lnb_file_offset = off;
370 lnb[i].lnb_page_offset = 0;
371 lnb[i].lnb_len = plen;
373 if (sz_in_block == bs)
374 lnb[i].lnb_data = abuf;
376 lnb[i].lnb_data = NULL;
378 /* this one is not supposed to fail */
379 lnb[i].lnb_page = kmem_to_page(abuf->b_data +
381 LASSERT(lnb[i].lnb_page);
383 lprocfs_counter_add(osd->od_stats,
384 LPROC_OSD_ZEROCOPY_IO, 1);
389 off_in_block += plen;
394 if (off_in_block == 0 && len < bs &&
395 off + len >= obj->oo_attr.la_size)
396 lprocfs_counter_add(osd->od_stats,
397 LPROC_OSD_TAIL_IO, 1);
399 /* can't use zerocopy, allocate temp. buffers */
400 while (sz_in_block > 0) {
401 plen = min_t(int, sz_in_block, PAGE_CACHE_SIZE);
403 lnb[i].lnb_file_offset = off;
404 lnb[i].lnb_page_offset = 0;
405 lnb[i].lnb_len = plen;
407 lnb[i].lnb_data = NULL;
409 lnb[i].lnb_page = alloc_page(OSD_GFP_IO);
410 if (unlikely(lnb[i].lnb_page == NULL))
411 GOTO(out_err, rc = -ENOMEM);
413 LASSERT(lnb[i].lnb_page->mapping == NULL);
414 lnb[i].lnb_page->mapping = (void *)obj;
416 atomic_inc(&osd->od_zerocopy_alloc);
417 lprocfs_counter_add(osd->od_stats,
418 LPROC_OSD_COPY_IO, 1);
432 osd_bufs_put(env, &obj->oo_dt, lnb, npages);
436 static int osd_bufs_get(const struct lu_env *env, struct dt_object *dt,
437 loff_t offset, ssize_t len, struct niobuf_local *lnb,
438 int rw, struct lustre_capa *capa)
440 struct osd_object *obj = osd_dt_obj(dt);
443 LASSERT(dt_object_exists(dt));
447 rc = osd_bufs_get_read(env, obj, offset, len, lnb);
449 rc = osd_bufs_get_write(env, obj, offset, len, lnb);
454 static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
455 struct niobuf_local *lnb, int npages)
457 struct osd_object *obj = osd_dt_obj(dt);
459 LASSERT(dt_object_exists(dt));
465 /* Return number of blocks that aren't mapped in the [start, start + size]
467 static int osd_count_not_mapped(struct osd_object *obj, uint64_t start,
470 dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)obj->oo_db;
481 if (dn->dn_maxblkid == 0) {
482 if (start + size <= dn->dn_datablksz)
484 if (start < dn->dn_datablksz)
485 start = dn->dn_datablksz;
486 /* assume largest block size */
487 blkshift = SPA_MAXBLOCKSHIFT;
489 /* blocksize can't change */
490 blkshift = dn->dn_datablkshift;
493 /* compute address of last block */
494 end = (start + size - 1) >> blkshift;
495 /* align start on block boundaries */
498 /* size is null, can't be mapped */
499 if (obj->oo_attr.la_size == 0 || dn->dn_maxblkid == 0)
500 GOTO(out, size = (end - start + 1) << blkshift);
502 /* beyond EOF, can't be mapped */
503 if (start > dn->dn_maxblkid)
504 GOTO(out, size = (end - start + 1) << blkshift);
507 for (blkid = start; blkid <= end; blkid++) {
508 if (blkid == dn->dn_maxblkid)
509 /* this one is mapped for sure */
511 if (blkid > dn->dn_maxblkid) {
512 size += (end - blkid + 1) << blkshift;
516 rc = dbuf_hold_impl(dn, 0, blkid, TRUE, FTAG, &db);
518 /* for ENOENT (block not mapped) and any other errors,
519 * assume the block isn't mapped */
520 size += 1 << blkshift;
532 static int osd_declare_write_commit(const struct lu_env *env,
533 struct dt_object *dt,
534 struct niobuf_local *lnb, int npages,
537 struct osd_object *obj = osd_dt_obj(dt);
538 struct osd_device *osd = osd_obj2dev(obj);
539 struct osd_thandle *oh;
542 int i, rc, flags = 0;
543 bool ignore_quota = false, synced = false;
547 LASSERT(dt_object_exists(dt));
553 oh = container_of0(th, struct osd_thandle, ot_super);
555 for (i = 0; i < npages; i++) {
557 /* ENOSPC, network RPC error, etc.
558 * We don't want to book space for pages which will be
559 * skipped in osd_write_commit(). Hence we skip pages
560 * with lnb_rc != 0 here too */
562 /* ignore quota for the whole request if any page is from
563 * client cache or written by root.
565 * XXX once we drop the 1.8 client support, the checking
566 * for whether page is from cache can be simplified as:
567 * !(lnb[i].flags & OBD_BRW_SYNC)
569 * XXX we could handle this on per-lnb basis as done by
571 if ((lnb[i].lnb_flags & OBD_BRW_NOQUOTA) ||
572 (lnb[i].lnb_flags & (OBD_BRW_FROM_GRANT | OBD_BRW_SYNC)) ==
576 /* first valid lnb */
577 offset = lnb[i].lnb_file_offset;
578 size = lnb[i].lnb_len;
581 if (offset + size == lnb[i].lnb_file_offset) {
582 /* this lnb is contiguous to the previous one */
583 size += lnb[i].lnb_len;
587 dmu_tx_hold_write(oh->ot_tx, obj->oo_db->db_object,
589 /* estimating space that will be consumed by a write is rather
590 * complicated with ZFS. As a consequence, we don't account for
591 * indirect blocks and quota overrun will be adjusted once the
592 * operation is committed, if required. */
593 space += osd_count_not_mapped(obj, offset, size);
595 offset = lnb[i].lnb_file_offset;
596 size = lnb[i].lnb_len;
600 dmu_tx_hold_write(oh->ot_tx, obj->oo_db->db_object,
602 space += osd_count_not_mapped(obj, offset, size);
605 dmu_tx_hold_sa(oh->ot_tx, obj->oo_sa_hdl, 0);
607 oh->ot_write_commit = 1; /* used in osd_trans_start() for fail_loc */
609 /* backend zfs filesystem might be configured to store multiple data
611 space *= osd->od_os->os_copies;
613 CDEBUG(D_QUOTA, "writting %d pages, reserving "LPD64"K of quota "
614 "space\n", npages, space);
617 /* acquire quota space if needed */
618 rc = osd_declare_quota(env, osd, obj->oo_attr.la_uid,
619 obj->oo_attr.la_gid, space, oh, true, &flags,
622 if (!synced && rc == -EDQUOT && (flags & QUOTA_FL_SYNC) != 0) {
623 dt_sync(env, th->th_dev);
625 CDEBUG(D_QUOTA, "retry after sync\n");
630 /* we need only to store the overquota flags in the first lnb for
631 * now, once we support multiple objects BRW, this code needs be
633 if (flags & QUOTA_FL_OVER_USRQUOTA)
634 lnb[0].lnb_flags |= OBD_BRW_OVER_USRQUOTA;
635 if (flags & QUOTA_FL_OVER_GRPQUOTA)
636 lnb[0].lnb_flags |= OBD_BRW_OVER_GRPQUOTA;
641 static int osd_write_commit(const struct lu_env *env, struct dt_object *dt,
642 struct niobuf_local *lnb, int npages,
645 struct osd_object *obj = osd_dt_obj(dt);
646 struct osd_device *osd = osd_obj2dev(obj);
647 struct osd_thandle *oh;
648 uint64_t new_size = 0;
652 LASSERT(dt_object_exists(dt));
656 oh = container_of0(th, struct osd_thandle, ot_super);
658 for (i = 0; i < npages; i++) {
659 CDEBUG(D_INODE, "write %u bytes at %u\n",
660 (unsigned) lnb[i].lnb_len,
661 (unsigned) lnb[i].lnb_file_offset);
664 /* ENOSPC, network RPC error, etc.
665 * Unlike ldiskfs, zfs allocates new blocks on rewrite,
666 * so we skip this page if lnb_rc is set to -ENOSPC */
667 CDEBUG(D_INODE, "obj "DFID": skipping lnb[%u]: rc=%d\n",
668 PFID(lu_object_fid(&dt->do_lu)), i,
673 if (lnb[i].lnb_page->mapping == (void *)obj) {
674 dmu_write(osd->od_os, obj->oo_db->db_object,
675 lnb[i].lnb_file_offset, lnb[i].lnb_len,
676 kmap(lnb[i].lnb_page), oh->ot_tx);
677 kunmap(lnb[i].lnb_page);
678 } else if (lnb[i].lnb_data) {
679 LASSERT(((unsigned long)lnb[i].lnb_data & 1) == 0);
680 /* buffer loaned for zerocopy, try to use it.
681 * notice that dmu_assign_arcbuf() is smart
682 * enough to recognize changed blocksize
683 * in this case it fallbacks to dmu_write() */
684 dmu_assign_arcbuf(obj->oo_db, lnb[i].lnb_file_offset,
685 lnb[i].lnb_data, oh->ot_tx);
686 /* drop the reference, otherwise osd_put_bufs()
687 * will be releasing it - bad! */
688 lnb[i].lnb_data = NULL;
689 atomic_dec(&osd->od_zerocopy_loan);
692 if (new_size < lnb[i].lnb_file_offset + lnb[i].lnb_len)
693 new_size = lnb[i].lnb_file_offset + lnb[i].lnb_len;
696 if (unlikely(new_size == 0)) {
697 /* no pages to write, no transno is needed */
699 /* it is important to return 0 even when all lnb_rc == -ENOSPC
700 * since ofd_commitrw_write() retries several times on ENOSPC */
704 write_lock(&obj->oo_attr_lock);
705 if (obj->oo_attr.la_size < new_size) {
706 obj->oo_attr.la_size = new_size;
707 write_unlock(&obj->oo_attr_lock);
708 /* osd_object_sa_update() will be copying directly from
709 * oo_attr into dbuf. any update within a single txg will copy
711 rc = osd_object_sa_update(obj, SA_ZPL_SIZE(osd),
712 &obj->oo_attr.la_size, 8, oh);
714 write_unlock(&obj->oo_attr_lock);
720 static int osd_read_prep(const struct lu_env *env, struct dt_object *dt,
721 struct niobuf_local *lnb, int npages)
723 struct osd_object *obj = osd_dt_obj(dt);
727 LASSERT(dt_object_exists(dt));
730 read_lock(&obj->oo_attr_lock);
731 size = obj->oo_attr.la_size;
732 read_unlock(&obj->oo_attr_lock);
734 for (i = 0; i < npages; i++) {
735 if (unlikely(lnb[i].lnb_rc < 0))
738 lnb[i].lnb_rc = lnb[i].lnb_len;
740 if (lnb[i].lnb_file_offset + lnb[i].lnb_len > size) {
741 lnb[i].lnb_rc = size - lnb[i].lnb_file_offset;
743 /* all subsequent rc should be 0 */
754 * Punch/truncate an object
756 * IN: db - dmu_buf of the object to free data in.
757 * off - start of section to free.
758 * len - length of section to free (DMU_OBJECT_END => to EOF).
760 * RETURN: 0 if success
761 * error code if failure
763 * The transaction passed to this routine must have
764 * dmu_tx_hold_sa() and if off < size, dmu_tx_hold_free()
765 * called and then assigned to a transaction group.
767 static int __osd_object_punch(objset_t *os, dmu_buf_t *db, dmu_tx_t *tx,
768 uint64_t size, uint64_t off, uint64_t len)
772 /* Assert that the transaction has been assigned to a
773 transaction group. */
774 LASSERT(tx->tx_txg != 0);
776 * Nothing to do if file already at desired length.
778 if (len == DMU_OBJECT_END && size == off)
782 rc = -dmu_free_range(os, db->db_object, off, len, tx);
787 static int osd_punch(const struct lu_env *env, struct dt_object *dt,
788 __u64 start, __u64 end, struct thandle *th,
789 struct lustre_capa *capa)
791 struct osd_object *obj = osd_dt_obj(dt);
792 struct osd_device *osd = osd_obj2dev(obj);
793 struct osd_thandle *oh;
798 LASSERT(dt_object_exists(dt));
799 LASSERT(osd_invariant(obj));
802 oh = container_of0(th, struct osd_thandle, ot_super);
804 write_lock(&obj->oo_attr_lock);
806 if (end == OBD_OBJECT_EOF || end >= obj->oo_attr.la_size)
807 len = DMU_OBJECT_END;
810 write_unlock(&obj->oo_attr_lock);
812 rc = __osd_object_punch(osd->od_os, obj->oo_db, oh->ot_tx,
813 obj->oo_attr.la_size, start, len);
815 if (len == DMU_OBJECT_END) {
816 write_lock(&obj->oo_attr_lock);
817 obj->oo_attr.la_size = start;
818 write_unlock(&obj->oo_attr_lock);
819 rc = osd_object_sa_update(obj, SA_ZPL_SIZE(osd),
820 &obj->oo_attr.la_size, 8, oh);
825 static int osd_declare_punch(const struct lu_env *env, struct dt_object *dt,
826 __u64 start, __u64 end, struct thandle *handle)
828 struct osd_object *obj = osd_dt_obj(dt);
829 struct osd_device *osd = osd_obj2dev(obj);
830 struct osd_thandle *oh;
834 oh = container_of0(handle, struct osd_thandle, ot_super);
836 read_lock(&obj->oo_attr_lock);
837 if (end == OBD_OBJECT_EOF || end >= obj->oo_attr.la_size)
838 len = DMU_OBJECT_END;
842 /* declare we'll free some blocks ... */
843 if (start < obj->oo_attr.la_size) {
844 read_unlock(&obj->oo_attr_lock);
845 dmu_tx_hold_free(oh->ot_tx, obj->oo_db->db_object, start, len);
847 read_unlock(&obj->oo_attr_lock);
850 /* ... and we'll modify size attribute */
851 dmu_tx_hold_sa(oh->ot_tx, obj->oo_sa_hdl, 0);
853 RETURN(osd_declare_quota(env, osd, obj->oo_attr.la_uid,
854 obj->oo_attr.la_gid, 0, oh, true, NULL,
859 struct dt_body_operations osd_body_ops = {
860 .dbo_read = osd_read,
861 .dbo_declare_write = osd_declare_write,
862 .dbo_write = osd_write,
863 .dbo_bufs_get = osd_bufs_get,
864 .dbo_bufs_put = osd_bufs_put,
865 .dbo_write_prep = osd_write_prep,
866 .dbo_declare_write_commit = osd_declare_write_commit,
867 .dbo_write_commit = osd_write_commit,
868 .dbo_read_prep = osd_read_prep,
869 .dbo_declare_punch = osd_declare_punch,
870 .dbo_punch = osd_punch,