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.
30 * Copyright (c) 2011, 2012, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ofd/ofd_obd.c
38 * Author: Andreas Dilger <adilger@whamcloud.com>
39 * Author: Alex Zhuravlev <bzzz@whamcloud.com>
40 * Author: Mike Pershin <tappro@whamcloud.com>
43 #define DEBUG_SUBSYSTEM S_FILTER
45 #include "ofd_internal.h"
46 #include <obd_cksum.h>
47 #include <lustre_quota.h>
49 static int ofd_export_stats_init(struct ofd_device *ofd,
50 struct obd_export *exp, void *client_nid)
52 struct obd_device *obd = ofd_obd(ofd);
53 struct nid_stat *stats;
59 if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid))
60 /* Self-export gets no proc entry */
63 rc = lprocfs_exp_setup(exp, client_nid, &newnid);
65 /* Mask error for already created
75 stats = exp->exp_nid_stats;
76 LASSERT(stats != NULL);
78 OBD_ALLOC(stats->nid_brw_stats, sizeof(struct brw_stats));
79 if (stats->nid_brw_stats == NULL)
80 GOTO(clean, rc = -ENOMEM);
82 for (i = 0; i < BRW_LAST; i++)
83 spin_lock_init(&stats->nid_brw_stats->hist[i].oh_lock);
85 rc = lprocfs_seq_create(stats->nid_proc, "brw_stats", 0644,
86 &ofd_per_nid_stats_fops, stats);
88 CWARN("Error adding the brw_stats file\n");
90 num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) +
93 stats->nid_stats = lprocfs_alloc_stats(num_stats,
94 LPROCFS_STATS_FLAG_NOPERCPU);
95 if (stats->nid_stats == NULL)
98 lprocfs_init_ops_stats(LPROC_OFD_LAST, stats->nid_stats);
99 lprocfs_counter_init(stats->nid_stats, LPROC_OFD_READ_BYTES,
100 LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
101 lprocfs_counter_init(stats->nid_stats, LPROC_OFD_WRITE_BYTES,
102 LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
104 rc = lprocfs_register_stats(stats->nid_proc, "stats",
109 rc = lprocfs_nid_ldlm_stats_init(stats);
111 lprocfs_free_stats(&stats->nid_stats);
120 static int ofd_parse_connect_data(const struct lu_env *env,
121 struct obd_export *exp,
122 struct obd_connect_data *data)
124 struct ofd_device *ofd = ofd_exp(exp);
125 struct filter_export_data *fed = &exp->exp_filter_data;
130 CDEBUG(D_RPCTRACE, "%s: cli %s/%p ocd_connect_flags: "LPX64
131 " ocd_version: %x ocd_grant: %d ocd_index: %u\n",
132 exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp,
133 data->ocd_connect_flags, data->ocd_version,
134 data->ocd_grant, data->ocd_index);
136 if (fed->fed_group != 0 && fed->fed_group != data->ocd_group) {
137 CWARN("!!! This export (nid %s) used object group %d "
138 "earlier; now it's trying to use group %d! This could "
139 "be a bug in the MDS. Please report to "
140 "http://bugs.whamcloud.com/\n",
141 obd_export_nid2str(exp), fed->fed_group,
145 fed->fed_group = data->ocd_group;
147 data->ocd_connect_flags &= OST_CONNECT_SUPPORTED;
148 exp->exp_connect_flags = data->ocd_connect_flags;
149 data->ocd_version = LUSTRE_VERSION_CODE;
151 /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */
152 if (data->ocd_connect_flags & OBD_CONNECT_MDS)
153 CDEBUG(D_HA, "%s: Received MDS connection for group %u\n",
154 exp->exp_obd->obd_name, data->ocd_group);
155 else if (data->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN)
158 if (ofd_grant_param_supp(exp)) {
159 exp->exp_filter_data.fed_pagesize = data->ocd_blocksize;
160 /* ocd_{blocksize,inodespace} are log2 values */
161 data->ocd_blocksize = ofd->ofd_blockbits;
162 data->ocd_inodespace = ofd->ofd_dt_conf.ddp_inodespace;
163 /* ocd_grant_extent is in 1K blocks */
164 data->ocd_grant_extent = ofd->ofd_dt_conf.ddp_grant_frag >> 10;
167 if (exp->exp_connect_flags & OBD_CONNECT_GRANT)
168 data->ocd_grant = ofd_grant_connect(env, exp, data->ocd_grant);
170 if (data->ocd_connect_flags & OBD_CONNECT_INDEX) {
171 struct lr_server_data *lsd = &ofd->ofd_lut.lut_lsd;
172 int index = lsd->lsd_ost_index;
174 if (!(lsd->lsd_feature_compat & OBD_COMPAT_OST)) {
175 /* this will only happen on the first connect */
176 lsd->lsd_ost_index = data->ocd_index;
177 lsd->lsd_feature_compat |= OBD_COMPAT_OST;
178 /* sync is not needed here as lut_client_add will
179 * set exp_need_sync flag */
180 tgt_server_data_update(env, &ofd->ofd_lut, 0);
181 } else if (index != data->ocd_index) {
182 LCONSOLE_ERROR_MSG(0x136, "Connection from %s to index"
183 " %u doesn't match actual OST index"
184 " %u in last_rcvd file, bad "
186 obd_export_nid2str(exp), index,
192 if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_SIZE)) {
193 data->ocd_brw_size = 65536;
194 } else if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
195 data->ocd_brw_size = min(data->ocd_brw_size,
196 (__u32)(PTLRPC_MAX_BRW_PAGES << CFS_PAGE_SHIFT));
197 if (data->ocd_brw_size == 0) {
198 CERROR("%s: cli %s/%p ocd_connect_flags: "LPX64
199 " ocd_version: %x ocd_grant: %d ocd_index: %u "
200 "ocd_brw_size is unexpectedly zero, "
201 "network data corruption?"
202 "Refusing connection of this client\n",
203 exp->exp_obd->obd_name,
204 exp->exp_client_uuid.uuid,
205 exp, data->ocd_connect_flags, data->ocd_version,
206 data->ocd_grant, data->ocd_index);
211 if (data->ocd_connect_flags & OBD_CONNECT_CKSUM) {
212 __u32 cksum_types = data->ocd_cksum_types;
214 /* The client set in ocd_cksum_types the checksum types it
215 * supports. We have to mask off the algorithms that we don't
217 data->ocd_cksum_types &= cksum_types_supported_server();
219 if (unlikely(data->ocd_cksum_types == 0)) {
220 CERROR("%s: Connect with checksum support but no "
221 "ocd_cksum_types is set\n",
222 exp->exp_obd->obd_name);
226 CDEBUG(D_RPCTRACE, "%s: cli %s supports cksum type %x, return "
227 "%x\n", exp->exp_obd->obd_name, obd_export_nid2str(exp),
228 cksum_types, data->ocd_cksum_types);
230 /* This client does not support OBD_CONNECT_CKSUM
231 * fall back to CRC32 */
232 CDEBUG(D_RPCTRACE, "%s: cli %s does not support "
233 "OBD_CONNECT_CKSUM, CRC32 will be used\n",
234 exp->exp_obd->obd_name, obd_export_nid2str(exp));
237 if (data->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
238 data->ocd_maxbytes = ofd->ofd_dt_conf.ddp_maxbytes;
243 static int ofd_obd_reconnect(const struct lu_env *env, struct obd_export *exp,
244 struct obd_device *obd, struct obd_uuid *cluuid,
245 struct obd_connect_data *data, void *localdata)
247 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
252 if (exp == NULL || obd == NULL || cluuid == NULL)
255 rc = lu_env_refill((struct lu_env *)env);
257 CERROR("Failure to refill session: '%d'\n", rc);
261 ofd_info_init(env, exp);
262 rc = ofd_parse_connect_data(env, exp, data);
264 ofd_export_stats_init(ofd, exp, localdata);
269 static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp,
270 struct obd_device *obd, struct obd_uuid *cluuid,
271 struct obd_connect_data *data, void *localdata)
273 struct obd_export *exp;
274 struct ofd_device *ofd;
275 struct lustre_handle conn = { 0 };
280 if (_exp == NULL || obd == NULL || cluuid == NULL)
283 ofd = ofd_dev(obd->obd_lu_dev);
285 rc = class_connect(&conn, obd, cluuid);
289 exp = class_conn2export(&conn);
290 LASSERT(exp != NULL);
292 rc = lu_env_refill((struct lu_env *)env);
294 CERROR("Failure to refill session: '%d'\n", rc);
298 ofd_info_init(env, exp);
300 rc = ofd_parse_connect_data(env, exp, data);
304 group = data->ocd_group;
305 if (obd->obd_replayable) {
306 struct tg_export_data *ted = &exp->exp_target_data;
308 memcpy(ted->ted_lcd->lcd_uuid, cluuid,
309 sizeof(ted->ted_lcd->lcd_uuid));
310 rc = tgt_client_new(env, exp);
313 ofd_export_stats_init(ofd, exp, localdata);
319 if (group > ofd->ofd_max_group) {
320 ofd->ofd_max_group = group;
321 rc = ofd_group_load(env, ofd, group);
325 class_disconnect(exp);
333 static int ofd_obd_disconnect(struct obd_export *exp)
335 struct ofd_device *ofd = ofd_dev(exp->exp_obd->obd_lu_dev);
342 class_export_get(exp);
344 if (!(exp->exp_flags & OBD_OPT_FORCE))
345 ofd_grant_sanity_check(ofd_obd(ofd), __FUNCTION__);
347 rc = server_disconnect_export(exp);
349 ofd_grant_discard(exp);
351 rc = lu_env_init(&env, LCT_DT_THREAD);
355 /* Do not erase record for recoverable client. */
356 if (exp->exp_obd->obd_replayable &&
357 (!exp->exp_obd->obd_fail || exp->exp_failed))
358 tgt_client_del(&env, exp);
361 class_export_put(exp);
365 static int ofd_init_export(struct obd_export *exp)
369 spin_lock_init(&exp->exp_filter_data.fed_lock);
370 CFS_INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list);
371 spin_lock(&exp->exp_lock);
372 exp->exp_connecting = 1;
373 spin_unlock(&exp->exp_lock);
375 /* self-export doesn't need client data and ldlm initialization */
376 if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
377 &exp->exp_client_uuid)))
380 rc = tgt_client_alloc(exp);
382 ldlm_init_export(exp);
384 CERROR("%s: Can't initialize export: rc %d\n",
385 exp->exp_obd->obd_name, rc);
389 static int ofd_destroy_export(struct obd_export *exp)
391 struct ofd_device *ofd = ofd_dev(exp->exp_obd->obd_lu_dev);
393 if (exp->exp_filter_data.fed_pending)
394 CERROR("%s: cli %s/%p has %lu pending on destroyed export"
395 "\n", exp->exp_obd->obd_name, exp->exp_client_uuid.uuid,
396 exp, exp->exp_filter_data.fed_pending);
398 target_destroy_export(exp);
400 if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
401 &exp->exp_client_uuid)))
404 ldlm_destroy_export(exp);
405 tgt_client_free(exp);
407 ofd_fmd_cleanup(exp);
410 * discard grants once we're sure no more
411 * interaction with the client is possible
413 ofd_grant_discard(exp);
414 ofd_fmd_cleanup(exp);
416 if (exp->exp_connect_flags & OBD_CONNECT_GRANT_SHRINK) {
417 if (ofd->ofd_tot_granted_clients > 0)
418 ofd->ofd_tot_granted_clients --;
421 if (!(exp->exp_flags & OBD_OPT_FORCE))
422 ofd_grant_sanity_check(exp->exp_obd, __FUNCTION__);
424 LASSERT(cfs_list_empty(&exp->exp_filter_data.fed_mod_list));
428 int ofd_postrecov(const struct lu_env *env, struct ofd_device *ofd)
430 struct lu_device *ldev = &ofd->ofd_dt_dev.dd_lu_dev;
432 CDEBUG(D_HA, "%s: recovery is over\n", ofd_obd(ofd)->obd_name);
433 return ldev->ld_ops->ldo_recovery_complete(env, ldev);
436 int ofd_obd_postrecov(struct obd_device *obd)
439 struct lu_device *ldev = obd->obd_lu_dev;
444 rc = lu_env_init(&env, LCT_DT_THREAD);
447 ofd_info_init(&env, obd->obd_self_export);
449 rc = ofd_postrecov(&env, ofd_dev(ldev));
455 static int ofd_adapt_sptlrpc_conf(const struct lu_env *env,
456 struct obd_device *obd, int initial)
458 struct filter_obd *fo = &obd->u.filter;
459 struct sptlrpc_rule_set tmp_rset;
462 sptlrpc_rule_set_init(&tmp_rset);
463 rc = sptlrpc_conf_target_get_rules(obd, &tmp_rset, initial);
465 CERROR("%s: failed get sptlrpc rules: rc = %d\n",
470 sptlrpc_target_update_exp_flavor(obd, &tmp_rset);
472 write_lock(&fo->fo_sptlrpc_lock);
473 sptlrpc_rule_set_free(&fo->fo_sptlrpc_rset);
474 fo->fo_sptlrpc_rset = tmp_rset;
475 write_unlock(&fo->fo_sptlrpc_lock);
480 static int ofd_set_mds_conn(struct obd_export *exp, void *val)
486 LCONSOLE_WARN("%s: received MDS connection from %s\n",
487 exp->exp_obd->obd_name, obd_export_nid2str(exp));
491 static int ofd_set_info_async(const struct lu_env *env, struct obd_export *exp,
492 __u32 keylen, void *key, __u32 vallen, void *val,
493 struct ptlrpc_request_set *set)
495 struct ofd_device *ofd = ofd_exp(exp);
500 if (exp->exp_obd == NULL) {
501 CDEBUG(D_IOCTL, "invalid export %p\n", exp);
505 if (KEY_IS(KEY_CAPA_KEY)) {
506 rc = ofd_update_capa_key(ofd, val);
508 CERROR("%s: update capability key failed: rc = %d\n",
509 exp->exp_obd->obd_name, rc);
510 } else if (KEY_IS(KEY_SPTLRPC_CONF)) {
511 ofd_adapt_sptlrpc_conf(env, exp->exp_obd, 0);
512 } else if (KEY_IS(KEY_MDS_CONN)) {
513 rc = ofd_set_mds_conn(exp, val);
514 } else if (KEY_IS(KEY_GRANT_SHRINK)) {
515 struct ost_body *body = val;
517 ofd_info_init(env, exp);
518 /** handle grant shrink, similar to a read request */
519 ofd_grant_prepare_read(env, exp, &body->oa);
521 CERROR("%s: Unsupported key %s\n",
522 exp->exp_obd->obd_name, (char*)key);
529 static int ofd_get_info(const struct lu_env *env, struct obd_export *exp,
530 __u32 keylen, void *key, __u32 *vallen, void *val,
531 struct lov_stripe_md *lsm)
533 struct ofd_device *ofd = ofd_exp(exp);
538 if (exp->exp_obd == NULL) {
539 CDEBUG(D_IOCTL, "invalid client export %p\n", exp);
543 if (KEY_IS(KEY_BLOCKSIZE)) {
544 __u32 *blocksize = val;
546 if (*vallen < sizeof(*blocksize))
548 *blocksize = 1 << ofd->ofd_dt_conf.ddp_block_shift;
550 *vallen = sizeof(*blocksize);
551 } else if (KEY_IS(KEY_BLOCKSIZE_BITS)) {
552 __u32 *blocksize_bits = val;
553 if (blocksize_bits) {
554 if (*vallen < sizeof(*blocksize_bits))
556 *blocksize_bits = ofd->ofd_dt_conf.ddp_block_shift;
558 *vallen = sizeof(*blocksize_bits);
559 } else if (KEY_IS(KEY_LAST_ID)) {
560 obd_id *last_id = val;
562 if (*vallen < sizeof(*last_id))
564 *last_id = ofd_last_id(ofd,
565 exp->exp_filter_data.fed_group);
567 *vallen = sizeof(*last_id);
568 } else if (KEY_IS(KEY_FIEMAP)) {
569 struct ofd_thread_info *info;
570 struct ofd_device *ofd = ofd_exp(exp);
571 struct ofd_object *fo;
572 struct ll_fiemap_info_key *fm_key = key;
575 *vallen = fiemap_count_to_size(
576 fm_key->fiemap.fm_extent_count);
580 info = ofd_info_init(env, exp);
582 fid_ostid_unpack(&info->fti_fid, &fm_key->oa.o_oi, 0);
584 CDEBUG(D_INODE, "get FIEMAP of object "DFID"\n",
585 PFID(&info->fti_fid));
587 fo = ofd_object_find(env, ofd, &info->fti_fid);
589 CERROR("%s: error finding object "DFID"\n",
590 exp->exp_obd->obd_name, PFID(&info->fti_fid));
593 struct ll_user_fiemap *fiemap = val;
595 ofd_read_lock(env, fo);
596 if (ofd_object_exists(fo)) {
597 *fiemap = fm_key->fiemap;
598 rc = dt_fiemap_get(env,
599 ofd_object_child(fo),
604 ofd_read_unlock(env, fo);
605 ofd_object_put(env, fo);
607 } else if (KEY_IS(KEY_SYNC_LOCK_CANCEL)) {
608 *((__u32 *) val) = ofd->ofd_sync_lock_cancel;
609 *vallen = sizeof(__u32);
611 CERROR("Not supported key %s\n", (char*)key);
618 /** helper function for statfs, also used by grant code */
619 int ofd_statfs_internal(const struct lu_env *env, struct ofd_device *ofd,
620 struct obd_statfs *osfs, __u64 max_age, int *from_cache)
624 spin_lock(&ofd->ofd_osfs_lock);
625 if (cfs_time_before_64(ofd->ofd_osfs_age, max_age) || max_age == 0) {
628 /* statfs data are too old, get up-to-date one.
629 * we must be cautious here since multiple threads might be
630 * willing to update statfs data concurrently and we must
631 * grant that cached statfs data are always consistent */
633 if (ofd->ofd_statfs_inflight == 0)
634 /* clear inflight counter if no users, although it would
635 * take a while to overflow this 64-bit counter ... */
636 ofd->ofd_osfs_inflight = 0;
637 /* notify ofd_grant_commit() that we want to track writes
638 * completed as of now */
639 ofd->ofd_statfs_inflight++;
640 /* record value of inflight counter before running statfs to
641 * compute the diff once statfs is completed */
642 unstable = ofd->ofd_osfs_inflight;
643 spin_unlock(&ofd->ofd_osfs_lock);
645 /* statfs can sleep ... hopefully not for too long since we can
646 * call it fairly often as space fills up */
647 rc = dt_statfs(env, ofd->ofd_osd, osfs);
651 spin_lock(&ofd->ofd_grant_lock);
652 spin_lock(&ofd->ofd_osfs_lock);
653 /* calculate how much space was written while we released the
655 unstable = ofd->ofd_osfs_inflight - unstable;
656 ofd->ofd_osfs_unstable = 0;
658 /* some writes completed while we were running statfs
659 * w/o the ofd_osfs_lock. Those ones got added to
660 * the cached statfs data that we are about to crunch.
661 * Take them into account in the new statfs data */
662 osfs->os_bavail -= min_t(obd_size, osfs->os_bavail,
663 unstable >> ofd->ofd_blockbits);
664 /* However, we don't really know if those writes got
665 * accounted in the statfs call, so tell
666 * ofd_grant_space_left() there is some uncertainty
667 * on the accounting of those writes.
668 * The purpose is to prevent spurious error messages in
669 * ofd_grant_space_left() since those writes might be
670 * accounted twice. */
671 ofd->ofd_osfs_unstable += unstable;
673 /* similarly, there is some uncertainty on write requests
674 * between prepare & commit */
675 ofd->ofd_osfs_unstable += ofd->ofd_tot_pending;
676 spin_unlock(&ofd->ofd_grant_lock);
678 /* finally udpate cached statfs data */
679 ofd->ofd_osfs = *osfs;
680 ofd->ofd_osfs_age = cfs_time_current_64();
682 ofd->ofd_statfs_inflight--; /* stop tracking */
683 if (ofd->ofd_statfs_inflight == 0)
684 ofd->ofd_osfs_inflight = 0;
685 spin_unlock(&ofd->ofd_osfs_lock);
690 /* use cached statfs data */
691 *osfs = ofd->ofd_osfs;
692 spin_unlock(&ofd->ofd_osfs_lock);
699 static int ofd_statfs(const struct lu_env *env, struct obd_export *exp,
700 struct obd_statfs *osfs, __u64 max_age, __u32 flags)
702 struct obd_device *obd = class_exp2obd(exp);
703 struct ofd_device *ofd = ofd_dev(exp->exp_obd->obd_lu_dev);
708 rc = ofd_statfs_internal(env, ofd, osfs, max_age, NULL);
712 /* at least try to account for cached pages. its still racy and
713 * might be under-reporting if clients haven't announced their
714 * caches with brw recently */
716 CDEBUG(D_SUPER | D_CACHE, "blocks cached "LPU64" granted "LPU64
717 " pending "LPU64" free "LPU64" avail "LPU64"\n",
718 ofd->ofd_tot_dirty, ofd->ofd_tot_granted, ofd->ofd_tot_pending,
719 osfs->os_bfree << ofd->ofd_blockbits,
720 osfs->os_bavail << ofd->ofd_blockbits);
722 osfs->os_bavail -= min_t(obd_size, osfs->os_bavail,
723 ((ofd->ofd_tot_dirty + ofd->ofd_tot_pending +
724 osfs->os_bsize - 1) >> ofd->ofd_blockbits));
726 /* The QoS code on the MDS does not care about space reserved for
727 * precreate, so take it out. */
728 if (exp->exp_connect_flags & OBD_CONNECT_MDS) {
729 struct filter_export_data *fed;
731 fed = &obd->obd_self_export->exp_filter_data;
732 osfs->os_bavail -= min_t(obd_size, osfs->os_bavail,
733 fed->fed_grant >> ofd->ofd_blockbits);
736 ofd_grant_sanity_check(obd, __FUNCTION__);
737 CDEBUG(D_CACHE, LPU64" blocks: "LPU64" free, "LPU64" avail; "
738 LPU64" objects: "LPU64" free; state %x\n",
739 osfs->os_blocks, osfs->os_bfree, osfs->os_bavail,
740 osfs->os_files, osfs->os_ffree, osfs->os_state);
742 if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOINO,
743 ofd->ofd_lut.lut_lsd.lsd_ost_index))
746 /* OS_STATE_READONLY can be set by OSD already */
747 if (ofd->ofd_raid_degraded)
748 osfs->os_state |= OS_STATE_DEGRADED;
750 if (obd->obd_self_export != exp && ofd_grant_compat(exp, ofd)) {
751 /* clients which don't support OBD_CONNECT_GRANT_PARAM
752 * should not see a block size > page size, otherwise
753 * cl_lost_grant goes mad. Therefore, we emulate a 4KB (=2^12)
754 * block size which is the biggest block size known to work
755 * with all client's page size. */
756 osfs->os_blocks <<= ofd->ofd_blockbits - COMPAT_BSIZE_SHIFT;
757 osfs->os_bfree <<= ofd->ofd_blockbits - COMPAT_BSIZE_SHIFT;
758 osfs->os_bavail <<= ofd->ofd_blockbits - COMPAT_BSIZE_SHIFT;
759 osfs->os_bsize = 1 << COMPAT_BSIZE_SHIFT;
762 if (OBD_FAIL_CHECK_VALUE(OBD_FAIL_OST_ENOSPC,
763 ofd->ofd_lut.lut_lsd.lsd_ost_index))
764 osfs->os_bfree = osfs->os_bavail = 2;
771 int ofd_setattr(const struct lu_env *env, struct obd_export *exp,
772 struct obd_info *oinfo, struct obd_trans_info *oti)
774 struct ofd_thread_info *info;
775 struct ofd_device *ofd = ofd_exp(exp);
776 struct ldlm_namespace *ns = ofd->ofd_namespace;
777 struct ldlm_resource *res;
778 struct ofd_object *fo;
779 struct obdo *oa = oinfo->oi_oa;
780 struct filter_fid *ff = NULL;
785 info = ofd_info_init(env, exp);
786 ofd_oti2info(info, oti);
788 fid_ostid_unpack(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
789 ofd_build_resid(&info->fti_fid, &info->fti_resid);
791 rc = ofd_auth_capa(exp, &info->fti_fid, oa->o_seq,
792 oinfo_capa(oinfo), CAPA_OPC_META_WRITE);
796 /* This would be very bad - accidentally truncating a file when
797 * changing the time or similar - bug 12203. */
798 if (oinfo->oi_oa->o_valid & OBD_MD_FLSIZE &&
799 oinfo->oi_policy.l_extent.end != OBD_OBJECT_EOF) {
800 static char mdsinum[48];
802 if (oinfo->oi_oa->o_valid & OBD_MD_FLFID)
803 snprintf(mdsinum, sizeof(mdsinum) - 1,
804 "of parent "DFID, oinfo->oi_oa->o_parent_seq,
805 oinfo->oi_oa->o_parent_oid, 0);
809 CERROR("%s: setattr from %s trying to truncate object "DFID
810 " %s\n", exp->exp_obd->obd_name,
811 obd_export_nid2str(exp), PFID(&info->fti_fid), mdsinum);
812 GOTO(out, rc = -EPERM);
815 fo = ofd_object_find(env, ofd, &info->fti_fid);
817 CERROR("%s: can't find object "DFID"\n",
818 exp->exp_obd->obd_name, PFID(&info->fti_fid));
819 GOTO(out, rc = PTR_ERR(fo));
822 la_from_obdo(&info->fti_attr, oinfo->oi_oa, oinfo->oi_oa->o_valid);
823 info->fti_attr.la_valid &= ~LA_TYPE;
825 if (oa->o_valid & OBD_MD_FLFID) {
826 ff = &info->fti_mds_fid;
827 ofd_prepare_fidea(ff, oa);
830 /* setting objects attributes (including owner/group) */
831 rc = ofd_attr_set(env, fo, &info->fti_attr, ff);
833 GOTO(out_unlock, rc);
835 res = ldlm_resource_get(ns, NULL, &info->fti_resid, LDLM_EXTENT, 0);
837 ldlm_res_lvbo_update(res, NULL, 0);
838 ldlm_resource_putref(res);
841 oinfo->oi_oa->o_valid = OBD_MD_FLID;
843 /* Quota release needs uid/gid info */
844 rc = ofd_attr_get(env, fo, &info->fti_attr);
845 obdo_from_la(oinfo->oi_oa, &info->fti_attr,
846 OFD_VALID_FLAGS | LA_UID | LA_GID);
847 ofd_info2oti(info, oti);
849 ofd_counter_incr(exp, LPROC_OFD_STATS_SETATTR, oti->oti_jobid, 1);
852 ofd_object_put(env, fo);
857 static int ofd_punch(const struct lu_env *env, struct obd_export *exp,
858 struct obd_info *oinfo, struct obd_trans_info *oti,
859 struct ptlrpc_request_set *rqset)
861 struct ofd_thread_info *info;
862 struct ofd_device *ofd = ofd_exp(exp);
863 struct ldlm_namespace *ns = ofd->ofd_namespace;
864 struct ldlm_resource *res;
865 struct ofd_object *fo;
866 struct filter_fid *ff = NULL;
871 info = ofd_info_init(env, exp);
872 ofd_oti2info(info, oti);
874 fid_ostid_unpack(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
875 ofd_build_resid(&info->fti_fid, &info->fti_resid);
877 CDEBUG(D_INODE, "calling punch for object "DFID", valid = "LPX64
878 ", start = "LPD64", end = "LPD64"\n", PFID(&info->fti_fid),
879 oinfo->oi_oa->o_valid, oinfo->oi_policy.l_extent.start,
880 oinfo->oi_policy.l_extent.end);
882 rc = ofd_auth_capa(exp, &info->fti_fid, oinfo->oi_oa->o_seq,
883 oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC);
887 fo = ofd_object_find(env, ofd, &info->fti_fid);
889 CERROR("%s: error finding object "DFID": rc = %ld\n",
890 exp->exp_obd->obd_name, PFID(&info->fti_fid),
892 GOTO(out_env, rc = PTR_ERR(fo));
895 LASSERT(oinfo->oi_policy.l_extent.end == OBD_OBJECT_EOF);
896 if (oinfo->oi_policy.l_extent.end == OBD_OBJECT_EOF) {
898 oinfo->oi_oa->o_size = oinfo->oi_policy.l_extent.start;
899 } else if (oinfo->oi_policy.l_extent.end >= oinfo->oi_oa->o_size) {
900 oinfo->oi_oa->o_size = oinfo->oi_policy.l_extent.end;
903 la_from_obdo(&info->fti_attr, oinfo->oi_oa,
904 OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME);
905 info->fti_attr.la_valid &= ~LA_TYPE;
906 info->fti_attr.la_size = oinfo->oi_policy.l_extent.start;
907 info->fti_attr.la_valid |= LA_SIZE;
909 if (oinfo->oi_oa->o_valid & OBD_MD_FLFID) {
910 ff = &info->fti_mds_fid;
911 ofd_prepare_fidea(ff, oinfo->oi_oa);
914 rc = ofd_object_punch(env, fo, oinfo->oi_policy.l_extent.start,
915 oinfo->oi_policy.l_extent.end, &info->fti_attr,
920 res = ldlm_resource_get(ns, NULL, &info->fti_resid, LDLM_EXTENT, 0);
922 ldlm_res_lvbo_update(res, NULL, 0);
923 ldlm_resource_putref(res);
926 oinfo->oi_oa->o_valid = OBD_MD_FLID;
927 /* Quota release needs uid/gid info */
928 rc = ofd_attr_get(env, fo, &info->fti_attr);
929 obdo_from_la(oinfo->oi_oa, &info->fti_attr,
930 OFD_VALID_FLAGS | LA_UID | LA_GID);
931 ofd_info2oti(info, oti);
933 ofd_counter_incr(exp, LPROC_OFD_STATS_PUNCH, oti->oti_jobid, 1);
936 ofd_object_put(env, fo);
941 static int ofd_destroy_by_fid(const struct lu_env *env,
942 struct ofd_device *ofd,
943 const struct lu_fid *fid, int orphan)
945 struct ofd_thread_info *info = ofd_info(env);
946 struct lustre_handle lockh;
947 __u64 flags = LDLM_AST_DISCARD_DATA, rc = 0;
948 ldlm_policy_data_t policy = {
949 .l_extent = { 0, OBD_OBJECT_EOF }
951 struct ofd_object *fo;
955 fo = ofd_object_find(env, ofd, fid);
959 /* Tell the clients that the object is gone now and that they should
960 * throw away any cached pages. */
961 ofd_build_resid(fid, &info->fti_resid);
962 rc = ldlm_cli_enqueue_local(ofd->ofd_namespace, &info->fti_resid,
963 LDLM_EXTENT, &policy, LCK_PW, &flags,
964 ldlm_blocking_ast, ldlm_completion_ast,
965 NULL, NULL, 0, LVB_T_NONE, NULL, &lockh);
967 /* We only care about the side-effects, just drop the lock. */
969 ldlm_lock_decref(&lockh, LCK_PW);
973 rc = ofd_object_destroy(env, fo, orphan);
975 ofd_object_put(env, fo);
979 int ofd_destroy(const struct lu_env *env, struct obd_export *exp,
980 struct obdo *oa, struct lov_stripe_md *md,
981 struct obd_trans_info *oti, struct obd_export *md_exp,
984 struct ofd_device *ofd = ofd_exp(exp);
985 struct ofd_thread_info *info;
991 info = ofd_info_init(env, exp);
992 ofd_oti2info(info, oti);
994 if (!(oa->o_valid & OBD_MD_FLGROUP))
997 /* check that o_misc makes sense */
998 if (oa->o_valid & OBD_MD_FLOBJCOUNT)
1001 count = 1; /* default case - single destroy */
1004 * There can be sequence of objects to destroy. Therefore this request
1005 * may have multiple transaction involved in. It is OK, we need only
1006 * the highest used transno to be reported back in reply but not for
1007 * replays, they must report their transno
1009 if (info->fti_transno == 0) /* not replay */
1010 info->fti_mult_trans = 1;
1014 fid_ostid_unpack(&info->fti_fid, &oa->o_oi, 0);
1015 lrc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 0);
1016 if (lrc == -ENOENT) {
1018 "%s: destroying non-existent object "DFID"\n",
1019 ofd_obd(ofd)->obd_name, PFID(&info->fti_fid));
1020 /* rewrite rc with -ENOENT only if it is 0 */
1023 } else if (lrc != 0) {
1024 CERROR("%s: error destroying object "DFID": %d\n",
1025 ofd_obd(ofd)->obd_name, PFID(&info->fti_fid),
1033 /* if we have transaction then there were some deletions, we don't
1034 * need to return ENOENT in that case because it will not wait
1035 * for commit of these deletions. The ENOENT must be returned only
1036 * if there were no transations.
1038 if (rc == -ENOENT) {
1039 if (info->fti_transno != 0)
1041 } else if (rc != 0) {
1043 * If we have at least one transaction then llog record
1044 * on server will be removed upon commit, so for rc != 0
1045 * we return no transno and llog record will be reprocessed.
1047 info->fti_transno = 0;
1049 ofd_info2oti(info, oti);
1053 static int ofd_orphans_destroy(const struct lu_env *env,
1054 struct obd_export *exp, struct ofd_device *ofd,
1057 struct ofd_thread_info *info = ofd_info(env);
1061 struct ost_id oi = oa->o_oi;
1065 LASSERT(exp != NULL);
1066 skip_orphan = !!(exp->exp_connect_flags & OBD_CONNECT_SKIP_ORPHAN);
1068 last = ofd_last_id(ofd, oa->o_seq);
1069 LCONSOLE_INFO("%s: deleting orphan objects from "LPU64" to "LPU64"\n",
1070 ofd_obd(ofd)->obd_name, oa->o_id + 1, last);
1072 for (oi.oi_id = last; oi.oi_id > oa->o_id; oi.oi_id--) {
1073 fid_ostid_unpack(&info->fti_fid, &oi, 0);
1074 rc = ofd_destroy_by_fid(env, ofd, &info->fti_fid, 1);
1075 if (rc && rc != -ENOENT) /* this is pretty fatal... */
1076 CEMERG("error destroying precreated id "LPU64": %d\n",
1079 ofd_last_id_set(ofd, oi.oi_id - 1, oa->o_seq);
1080 /* update last_id on disk periodically so that if we
1081 * restart * we don't need to re-scan all of the just
1082 * deleted objects. */
1083 if ((oi.oi_id & 511) == 0)
1084 ofd_last_id_write(env, ofd, oa->o_seq);
1087 CDEBUG(D_HA, "%s: after destroy: set last_objids["LPU64"] = "LPU64"\n",
1088 ofd_obd(ofd)->obd_name, oa->o_seq, oa->o_id);
1090 rc = ofd_last_id_write(env, ofd, oa->o_seq);
1092 /* don't reuse orphan object, return last used objid */
1099 int ofd_create(const struct lu_env *env, struct obd_export *exp,
1100 struct obdo *oa, struct lov_stripe_md **ea,
1101 struct obd_trans_info *oti)
1103 struct ofd_device *ofd = ofd_exp(exp);
1104 struct ofd_thread_info *info;
1109 info = ofd_info_init(env, exp);
1110 ofd_oti2info(info, oti);
1112 LASSERT(oa->o_seq >= FID_SEQ_OST_MDT0);
1113 LASSERT(oa->o_valid & OBD_MD_FLGROUP);
1115 CDEBUG(D_INFO, "ofd_create(oa->o_seq="LPU64",oa->o_id="LPU64")\n",
1116 oa->o_seq, oa->o_id);
1118 if ((oa->o_valid & OBD_MD_FLFLAGS) &&
1119 (oa->o_flags & OBD_FL_RECREATE_OBJS)) {
1120 if (!ofd_obd(ofd)->obd_recovering ||
1121 oa->o_id > ofd_last_id(ofd, oa->o_seq)) {
1122 CERROR("recreate objid "LPU64" > last id "LPU64"\n",
1123 oa->o_id, ofd_last_id(ofd, oa->o_seq));
1124 GOTO(out_nolock, rc = -EINVAL);
1126 /* do nothing because we create objects during first write */
1127 GOTO(out_nolock, rc = 0);
1129 /* former ofd_handle_precreate */
1130 if ((oa->o_valid & OBD_MD_FLFLAGS) &&
1131 (oa->o_flags & OBD_FL_DELORPHAN)) {
1132 /* destroy orphans */
1133 if (oti->oti_conn_cnt < exp->exp_conn_cnt) {
1134 CERROR("%s: dropping old orphan cleanup request\n",
1135 ofd_obd(ofd)->obd_name);
1136 GOTO(out_nolock, rc = 0);
1138 /* This causes inflight precreates to abort and drop lock */
1139 set_bit(oa->o_seq, &ofd->ofd_destroys_in_progress);
1140 mutex_lock(&ofd->ofd_create_locks[oa->o_seq]);
1141 if (!test_bit(oa->o_seq, &ofd->ofd_destroys_in_progress)) {
1142 CERROR("%s:["LPU64"] destroys_in_progress already cleared\n",
1143 exp->exp_obd->obd_name, oa->o_seq);
1146 diff = oa->o_id - ofd_last_id(ofd, oa->o_seq);
1147 CDEBUG(D_HA, "ofd_last_id() = "LPU64" -> diff = %d\n",
1148 ofd_last_id(ofd, oa->o_seq), diff);
1149 if (-diff > OST_MAX_PRECREATE) {
1150 /* FIXME: should reset precreate_next_id on MDS */
1152 } else if (diff < 0) {
1153 rc = ofd_orphans_destroy(env, exp, ofd, oa);
1154 clear_bit(oa->o_seq, &ofd->ofd_destroys_in_progress);
1156 /* XXX: Used by MDS for the first time! */
1157 clear_bit(oa->o_seq, &ofd->ofd_destroys_in_progress);
1160 mutex_lock(&ofd->ofd_create_locks[oa->o_seq]);
1161 if (oti->oti_conn_cnt < exp->exp_conn_cnt) {
1162 CERROR("%s: dropping old precreate request\n",
1163 ofd_obd(ofd)->obd_name);
1166 /* only precreate if group == 0 and o_id is specfied */
1167 if (!fid_seq_is_mdt(oa->o_seq) || oa->o_id == 0) {
1168 diff = 1; /* shouldn't we create this right now? */
1170 diff = oa->o_id - ofd_last_id(ofd, oa->o_seq);
1174 cfs_time_t enough_time = cfs_time_shift(DISK_TIMEOUT);
1179 if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
1180 !(oa->o_flags & OBD_FL_DELORPHAN)) {
1181 /* don't enforce grant during orphan recovery */
1182 rc = ofd_grant_create(env,
1183 ofd_obd(ofd)->obd_self_export,
1186 CDEBUG(D_HA, "%s: failed to acquire grant space"
1187 "for precreate (%d)\n",
1188 ofd_obd(ofd)->obd_name, diff);
1194 next_id = ofd_last_id(ofd, oa->o_seq) + 1;
1195 count = ofd_precreate_batch(ofd, diff);
1197 CDEBUG(D_HA, "%s: reserve %d objects in group "LPU64
1198 " at "LPU64"\n", ofd_obd(ofd)->obd_name,
1199 count, oa->o_seq, next_id);
1201 if (cfs_time_after(jiffies, enough_time)) {
1202 LCONSOLE_WARN("%s: Slow creates, %d/%d objects"
1203 " created at a rate of %d/s\n",
1204 ofd_obd(ofd)->obd_name,
1205 created, diff + created,
1206 created / DISK_TIMEOUT);
1210 rc = ofd_precreate_objects(env, ofd, next_id,
1215 } else if (rc < 0) {
1220 /* some objects got created, we can return
1221 * them, even if last creation failed */
1222 oa->o_id = ofd_last_id(ofd, oa->o_seq);
1225 CERROR("unable to precreate: %d\n", rc);
1226 oa->o_id = ofd_last_id(ofd, oa->o_seq);
1229 oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
1231 if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
1232 !(oa->o_flags & OBD_FL_DELORPHAN))
1233 ofd_grant_commit(env, ofd_obd(ofd)->obd_self_export,
1237 ofd_info2oti(info, oti);
1239 mutex_unlock(&ofd->ofd_create_locks[oa->o_seq]);
1241 if (rc == 0 && ea != NULL) {
1242 struct lov_stripe_md *lsm = *ea;
1244 lsm->lsm_object_id = oa->o_id;
1249 int ofd_getattr(const struct lu_env *env, struct obd_export *exp,
1250 struct obd_info *oinfo)
1252 struct ofd_device *ofd = ofd_exp(exp);
1253 struct ofd_thread_info *info;
1254 struct ofd_object *fo;
1260 info = ofd_info_init(env, exp);
1262 fid_ostid_unpack(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
1263 rc = ofd_auth_capa(exp, &info->fti_fid, oinfo->oi_oa->o_seq,
1264 oinfo_capa(oinfo), CAPA_OPC_META_READ);
1268 fo = ofd_object_find(env, ofd, &info->fti_fid);
1270 GOTO(out, rc = PTR_ERR(fo));
1271 LASSERT(fo != NULL);
1272 rc = ofd_attr_get(env, fo, &info->fti_attr);
1273 oinfo->oi_oa->o_valid = OBD_MD_FLID;
1275 obdo_from_la(oinfo->oi_oa, &info->fti_attr,
1276 OFD_VALID_FLAGS | LA_UID | LA_GID);
1278 /* Store object version in reply */
1279 curr_version = dt_version_get(env, ofd_object_child(fo));
1280 if ((__s64)curr_version != -EOPNOTSUPP) {
1281 oinfo->oi_oa->o_valid |= OBD_MD_FLDATAVERSION;
1282 oinfo->oi_oa->o_data_version = curr_version;
1284 ofd_object_put(env, fo);
1289 static int ofd_sync(const struct lu_env *env, struct obd_export *exp,
1290 struct obd_info *oinfo, obd_size start, obd_size end,
1291 struct ptlrpc_request_set *set)
1293 struct ofd_device *ofd = ofd_exp(exp);
1294 struct ofd_thread_info *info;
1295 struct ofd_object *fo;
1300 /* if no objid is specified, it means "sync whole filesystem" */
1301 if (oinfo->oi_oa == NULL || !(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
1302 rc = dt_sync(env, ofd->ofd_osd);
1306 info = ofd_info_init(env, exp);
1307 fid_ostid_unpack(&info->fti_fid, &oinfo->oi_oa->o_oi, 0);
1309 rc = ofd_auth_capa(exp, &info->fti_fid, oinfo->oi_oa->o_seq,
1310 oinfo_capa(oinfo), CAPA_OPC_OSS_TRUNC);
1314 fo = ofd_object_find(env, ofd, &info->fti_fid);
1316 CERROR("%s: error finding object "DFID": rc = %ld\n",
1317 exp->exp_obd->obd_name, PFID(&info->fti_fid),
1319 GOTO(out, rc = PTR_ERR(fo));
1322 if (!ofd_object_exists(fo))
1323 GOTO(put, rc = -ENOENT);
1325 if (dt_version_get(env, ofd_object_child(fo)) >
1326 ofd_obd(ofd)->obd_last_committed) {
1327 rc = dt_object_sync(env, ofd_object_child(fo));
1332 oinfo->oi_oa->o_valid = OBD_MD_FLID;
1333 rc = ofd_attr_get(env, fo, &info->fti_attr);
1334 obdo_from_la(oinfo->oi_oa, &info->fti_attr, OFD_VALID_FLAGS);
1336 ofd_counter_incr(exp, LPROC_OFD_STATS_SYNC, oinfo->oi_jobid, 1);
1339 ofd_object_put(env, fo);
1344 int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1345 void *karg, void *uarg)
1348 struct ofd_device *ofd = ofd_exp(exp);
1349 struct obd_device *obd = ofd_obd(ofd);
1354 CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd);
1355 rc = lu_env_init(&env, LCT_LOCAL);
1360 case OBD_IOC_ABORT_RECOVERY:
1361 CERROR("%s: aborting recovery\n", obd->obd_name);
1362 target_stop_recovery_thread(obd);
1365 CDEBUG(D_RPCTRACE, "syncing ost %s\n", obd->obd_name);
1366 rc = dt_sync(&env, ofd->ofd_osd);
1368 case OBD_IOC_SET_READONLY:
1369 rc = dt_sync(&env, ofd->ofd_osd);
1371 rc = dt_ro(&env, ofd->ofd_osd);
1374 CERROR("%s: not supported cmd = %d\n", obd->obd_name, cmd);
1382 static int ofd_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
1389 case OBD_CLEANUP_EARLY:
1391 case OBD_CLEANUP_EXPORTS:
1392 target_cleanup_recovery(obd);
1398 static int ofd_ping(const struct lu_env *env, struct obd_export *exp)
1400 ofd_fmd_expire(exp);
1404 static int ofd_health_check(const struct lu_env *nul, struct obd_device *obd)
1406 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
1407 struct ofd_thread_info *info;
1409 #ifdef USE_HEALTH_CHECK_WRITE
1414 /* obd_proc_read_health pass NULL env, we need real one */
1415 rc = lu_env_init(&env, LCT_DT_THREAD);
1419 info = ofd_info_init(&env, NULL);
1420 rc = dt_statfs(&env, ofd->ofd_osd, &info->fti_u.osfs);
1424 if (info->fti_u.osfs.os_state == OS_STATE_READONLY)
1425 GOTO(out, rc = -EROFS);
1427 #ifdef USE_HEALTH_CHECK_WRITE
1428 OBD_ALLOC(info->fti_buf.lb_buf, CFS_PAGE_SIZE);
1429 if (info->fti_buf.lb_buf == NULL)
1430 GOTO(out, rc = -ENOMEM);
1432 info->fti_buf.lb_len = CFS_PAGE_SIZE;
1435 th = dt_trans_create(&env, ofd->ofd_osd);
1437 GOTO(out, rc = PTR_ERR(th));
1439 rc = dt_declare_record_write(&env, ofd->ofd_health_check_file,
1440 info->fti_buf.lb_len, info->fti_off, th);
1442 th->th_sync = 1; /* sync IO is needed */
1443 rc = dt_trans_start_local(&env, ofd->ofd_osd, th);
1445 rc = dt_record_write(&env, ofd->ofd_health_check_file,
1446 &info->fti_buf, &info->fti_off,
1449 dt_trans_stop(&env, ofd->ofd_osd, th);
1451 OBD_FREE(info->fti_buf.lb_buf, CFS_PAGE_SIZE);
1453 CDEBUG(D_INFO, "write 1 page synchronously for checking io rc %d\n",rc);
1461 * Handle quota control requests to consult current usage/limit.
1463 * \param obd - is the obd device associated with the ofd
1464 * \param exp - is the client's export
1465 * \param oqctl - is the obd_quotactl request to be processed
1467 static int ofd_quotactl(struct obd_device *obd, struct obd_export *exp,
1468 struct obd_quotactl *oqctl)
1470 struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
1475 /* report success for quota on/off for interoperability with current MDT
1477 if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF)
1480 rc = lu_env_init(&env, LCT_DT_THREAD);
1484 rc = lquotactl_slv(&env, ofd->ofd_osd, oqctl);
1490 struct obd_ops ofd_obd_ops = {
1491 .o_owner = THIS_MODULE,
1492 .o_connect = ofd_obd_connect,
1493 .o_reconnect = ofd_obd_reconnect,
1494 .o_disconnect = ofd_obd_disconnect,
1495 .o_set_info_async = ofd_set_info_async,
1496 .o_get_info = ofd_get_info,
1497 .o_create = ofd_create,
1498 .o_statfs = ofd_statfs,
1499 .o_setattr = ofd_setattr,
1500 .o_preprw = ofd_preprw,
1501 .o_commitrw = ofd_commitrw,
1502 .o_destroy = ofd_destroy,
1503 .o_init_export = ofd_init_export,
1504 .o_destroy_export = ofd_destroy_export,
1505 .o_postrecov = ofd_obd_postrecov,
1506 .o_punch = ofd_punch,
1507 .o_getattr = ofd_getattr,
1509 .o_iocontrol = ofd_iocontrol,
1510 .o_precleanup = ofd_precleanup,
1512 .o_health_check = ofd_health_check,
1513 .o_quotactl = ofd_quotactl,