Motr  M0
storage_dev.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_IOSERVICE
23 #include "lib/trace.h"
24 
25 #include "lib/errno.h"
26 #include "lib/memory.h"
27 #include "lib/finject.h" /* M0_FI_ENABLED */
28 #include "lib/string.h" /* m0_strdup */
29 #include "balloc/balloc.h" /* b2m0 */
30 #include "conf/obj.h" /* m0_conf_sdev */
31 #include "conf/confc.h" /* m0_confc_from_obj */
32 #include "conf/helpers.h" /* m0_conf_drive_get */
33 #include "conf/obj_ops.h" /* M0_CONF_DIRNEXT */
34 #include "stob/ad.h" /* m0_stob_ad_domain2balloc */
35 #include "stob/linux.h" /* m0_stob_linux_domain_directio */
36 #include "stob/stob.h" /* m0_stob_id_get */
37 #include "ioservice/fid_convert.h" /* m0_fid_validate_linuxstob */
38 #include "ioservice/storage_dev.h"
39 #include "reqh/reqh.h" /* m0_reqh */
40 #include <unistd.h> /* fdatasync */
41 #include <sys/vfs.h> /* fstatfs */
42 #ifndef __KERNEL__
43 # include "pool/pool.h" /* m0_pools_common */
44 #endif
45 
56 M0_TL_DESCR_DEFINE(storage_dev, "storage_dev", M0_INTERNAL,
57  struct m0_storage_dev, isd_linkage, isd_magic,
59 
60 M0_TL_DEFINE(storage_dev, M0_INTERNAL, struct m0_storage_dev);
61 
62 static bool storage_dev_state_update_cb(struct m0_clink *link);
63 static bool storage_devs_conf_expired_cb(struct m0_clink *link);
64 static bool storage_devs_conf_ready_async_cb(struct m0_clink *link);
65 
66 static bool storage_devs_is_locked(const struct m0_storage_devs *devs)
67 {
68  return devs->sds_locks_disabled || m0_mutex_is_locked(&devs->sds_lock);
69 }
70 
71 M0_INTERNAL void m0_storage_devs_lock(struct m0_storage_devs *devs)
72 {
73  if (!devs->sds_locks_disabled)
74  m0_mutex_lock(&devs->sds_lock);
75 }
76 
77 M0_INTERNAL void m0_storage_devs_unlock(struct m0_storage_devs *devs)
78 {
79  if (!devs->sds_locks_disabled)
80  m0_mutex_unlock(&devs->sds_lock);
81 }
82 
83 M0_INTERNAL int m0_storage_devs_init(struct m0_storage_devs *devs,
85  struct m0_be_seg *be_seg,
86  struct m0_stob_domain *bstore_dom,
87  struct m0_reqh *reqh)
88 {
89  M0_ENTRY();
90  M0_PRE(equi(bstore_dom != NULL, type == M0_STORAGE_DEV_TYPE_AD));
91 
92  devs->sds_type = type;
93  devs->sds_be_seg = be_seg;
94  devs->sds_back_domain = bstore_dom;
95  devs->sds_locks_disabled = false;
96  storage_dev_tlist_init(&devs->sds_devices);
97  m0_mutex_init(&devs->sds_lock);
103  &devs->sds_conf_ready_async);
104  return M0_RC(m0_parallel_pool_init(&devs->sds_pool, 10, 20));
105 }
106 
107 M0_INTERNAL void m0_storage_devs_fini(struct m0_storage_devs *devs)
108 {
109  struct m0_storage_dev *dev;
110 
111  M0_ENTRY();
116  m0_clink_fini(&devs->sds_conf_exp);
118 
119  m0_tl_for(storage_dev, &devs->sds_devices, dev) {
120  M0_LOG(M0_DEBUG, "fini: dev=%p, ref=%" PRIi64
121  "state=%d type=%d, %"PRIu64,
122  dev,
123  m0_ref_read(&dev->isd_ref),
124  dev->isd_ha_state,
125  dev->isd_srv_type,
126  dev->isd_cid);
127  } m0_tl_endfor;
128 
129  storage_dev_tlist_fini(&devs->sds_devices);
130  m0_mutex_fini(&devs->sds_lock);
131  M0_LEAVE();
132 }
133 
134 M0_INTERNAL void m0_storage_devs_use_directio(struct m0_storage_devs *devs,
135  bool directio)
136 {
137  M0_PRE(storage_dev_tlist_is_empty(&devs->sds_devices));
140  directio));
141 
142  devs->sds_use_directio = directio;
143 }
144 
145 M0_INTERNAL void m0_storage_devs_locks_disable(struct m0_storage_devs *devs)
146 {
148  devs->sds_locks_disabled = true;
149 }
150 
151 M0_INTERNAL struct m0_storage_dev *
153  uint64_t cid)
154 {
156  return m0_tl_find(storage_dev, dev, &devs->sds_devices,
157  dev->isd_cid == cid);
158 }
159 
160 M0_INTERNAL struct m0_storage_dev *
162  struct m0_stob_domain *dom)
163 {
165  return m0_tl_find(storage_dev, dev, &devs->sds_devices,
166  dev->isd_domain == dom);
167 }
168 
169 M0_INTERNAL void m0_storage_dev_clink_add(struct m0_clink *link,
170  struct m0_chan *chan)
171 {
173  m0_clink_add_lock(chan, link);
174 }
175 
176 M0_INTERNAL void m0_storage_dev_clink_del(struct m0_clink *link)
177 {
178  m0_clink_cleanup(link);
179  m0_clink_fini(link);
180 }
181 
182 static bool storage_dev_state_update_cb(struct m0_clink *link)
183 {
184  struct m0_storage_dev *dev =
185  container_of(link, struct m0_storage_dev, isd_clink);
186  struct m0_conf_obj *obj =
187  container_of(link->cl_chan, struct m0_conf_obj, co_ha_chan);
189  dev->isd_ha_state = obj->co_ha_state;
190  return true;
191 }
192 
193 static void dev_filename_update(struct m0_storage_dev *dev,
194  const struct m0_conf_obj *obj)
195 {
196  M0_ENTRY();
197  m0_free0(&dev->isd_filename);
198  dev->isd_filename = m0_strdup(
199  M0_CONF_CAST(obj, m0_conf_sdev)->sd_filename);
200  if (dev->isd_filename == NULL)
201  M0_ERR_INFO(-ENOMEM, "Unable to duplicate sd_filename %s for "
202  FID_F, M0_CONF_CAST(obj, m0_conf_sdev)->sd_filename,
203  FID_P(&obj->co_id));
204  M0_LEAVE();
205 }
206 
208 {
209  struct m0_storage_dev *dev;
210  struct m0_conf_obj *obj;
211  struct m0_storage_devs *storage_devs = M0_AMB(storage_devs, clink,
212  sds_conf_exp);
213  struct m0_reqh *reqh = M0_AMB(reqh, clink->cl_chan,
215  struct m0_pools_common *pc = reqh->rh_pools;
217  struct m0_fid sdev_fid;
218 
219  if (M0_FI_ENABLED("skip_storage_devs_expire_cb"))
220  return true;
221 
222  M0_ENTRY();
223  m0_storage_devs_lock(storage_devs);
224  m0_tl_for (storage_dev, &storage_devs->sds_devices, dev) {
225  /*
226  * Step 1. Need to save current sdev filename attribute in
227  * order to use it later in storage_dev_update_by_conf() when
228  * new conf is ready.
229  */
230  if (dev->isd_srv_type != M0_CST_IOS &&
231  dev->isd_srv_type != M0_CST_CAS &&
232  /* In some cases indices are valid even though it is
233  * non-IOS/non-CAS device. i.e. in spiel-conf-ut big-db
234  * test, device ID is hardcoded to
235  * M0_AD_STOB_DOM_KEY_DEFAULT (0x1), In such case should
236  * not skip through loop.
237  */
238  dev->isd_cid >= pc->pc_nr_devices) {
239  /*
240  * For non-IOS/non-CAS devices base device ids
241  * (dev->isd_cid) are lifted up by design and they
242  * can not be valid indices for pc->pc_dev2svc[ ].
243  */
244  continue;
245  }
247 
248  sdev_fid = pc->pc_dev2svc[dev->isd_cid].pds_sdev_fid;
249  if (m0_fid_is_set(&sdev_fid) &&
250  /*
251  * Not all storage devices have a corresponding m0_conf_sdev
252  * object.
253  */
254  (obj = m0_conf_cache_lookup(cache, &sdev_fid)) != NULL)
255  dev_filename_update(dev, obj);
256  /*
257  * Step 2. Un-link from HA chan to let conf cache be ultimately
258  * drained by rconfc.
259  */
260  if (!m0_clink_is_armed(&dev->isd_clink))
261  continue;
262  obj = M0_AMB(obj, dev->isd_clink.cl_chan, co_ha_chan);
264  if (!m0_fid_is_set(&sdev_fid))
265  /* Step 1, second chance to catch up with filename. */
266  dev_filename_update(dev, obj);
267  /* Un-link from HA chan and un-pin the conf object. */
271  } m0_tl_endfor;
272  m0_storage_devs_unlock(storage_devs);
273  M0_LEAVE();
274  return true;
275 }
276 
278  struct m0_conf_sdev *sdev,
279  struct m0_storage_devs *storage_devs)
280 {
281  struct m0_storage_dev *dev_new;
282  int rc;
283 
284  M0_ENTRY("dev cid:%" PRIx64 ", fid: "FID_F", old: %s, new: %s",
285  dev->isd_cid, FID_P(&sdev->sd_obj.co_id), dev->isd_filename,
286  M0_MEMBER(sdev, sd_filename));
287  M0_PRE(sdev != NULL);
288  M0_PRE(storage_devs_is_locked(storage_devs));
289 
290  if (m0_streq(dev->isd_filename, sdev->sd_filename))
291  return M0_RC(0); /* the dev did not change */
292 
293  M0_PRE(m0_ref_read(&dev->isd_ref) == 1);
295  rc = m0_storage_dev_new_by_conf(storage_devs, sdev, false, &dev_new);
296  if (rc != 0)
297  return M0_ERR(rc);
298  M0_ASSERT(dev_new != NULL);
299  m0_storage_dev_attach(dev_new, storage_devs);
300  return M0_RC(0);
301 }
302 
303 static void storage_devs_conf_refresh(struct m0_storage_devs *storage_devs,
304  struct m0_reqh *reqh)
305 {
306  struct m0_confc *confc = m0_reqh2confc(reqh);
307  struct m0_storage_dev *dev;
308  struct m0_fid sdev_fid;
309  struct m0_conf_sdev *conf_sdev;
310  int rc;
311 
312  M0_ENTRY();
313  M0_PRE(storage_devs_is_locked(storage_devs));
314 
315  m0_tl_for(storage_dev, &storage_devs->sds_devices, dev) {
317  &sdev_fid);
318  if (rc != 0)
319  /* Not all storage devices have a corresponding
320  * m0_conf_sdev object.
321  */
322  continue;
323  conf_sdev = NULL;
324  rc = m0_conf_sdev_get(confc, &sdev_fid, &conf_sdev) ?:
325  storage_dev_update_by_conf(dev, conf_sdev,
326  storage_devs);
327  if (rc != 0)
328  M0_ERR(rc);
329  if (conf_sdev != NULL)
330  m0_confc_close(&conf_sdev->sd_obj);
331  } m0_tl_endfor;
332  M0_LEAVE();
333 }
334 
336 {
337  struct m0_storage_devs *storage_devs = M0_AMB(storage_devs, clink,
339  struct m0_reqh *reqh = M0_AMB(reqh, clink->cl_chan,
341  struct m0_storage_dev *dev;
342  struct m0_confc *confc = m0_reqh2confc(reqh);
343  struct m0_fid sdev_fid;
344  struct m0_conf_sdev *conf_sdev = NULL;
345  struct m0_conf_service *conf_service;
346  struct m0_conf_obj *srv_obj;
347  int rc;
348 
349  if (M0_FI_ENABLED("skip_storage_devs_ready_cb"))
350  return true;
351 
352  M0_ENTRY();
353  m0_storage_devs_lock(storage_devs);
354  storage_devs_conf_refresh(storage_devs, reqh);
355 
356  m0_tl_for (storage_dev, &storage_devs->sds_devices, dev) {
357  rc = m0_conf_device_cid_to_fid(confc, dev->isd_cid, &sdev_fid);
358  if (rc != 0)
359  /* Not all storage devices have a corresponding
360  * m0_conf_sdev object.
361  */
362  continue;
363  rc = m0_conf_sdev_get(confc, &sdev_fid, &conf_sdev);
364  M0_ASSERT_INFO(rc == 0, "No sdev: "FID_F, FID_P(&sdev_fid));
365  M0_ASSERT(conf_sdev != NULL);
366  M0_LOG(M0_DEBUG, "cid:0x%" PRIx64 " -> sdev_fid:"FID_F" idx:0x%x",
367  dev->isd_cid, FID_P(&sdev_fid), conf_sdev->sd_dev_idx);
368  if (!m0_clink_is_armed(&dev->isd_clink))
370  &conf_sdev->sd_obj.co_ha_chan);
371  dev->isd_ha_state = conf_sdev->sd_obj.co_ha_state;
372  srv_obj = m0_conf_obj_grandparent(&conf_sdev->sd_obj);
373  conf_service = M0_CONF_CAST(srv_obj, m0_conf_service);
374  dev->isd_srv_type = conf_service->cs_type;
375  } m0_tl_endfor;
376 
377  m0_storage_devs_unlock(storage_devs);
378  M0_LEAVE();
379  return true;
380 }
381 
383  struct m0_storage_devs *devs,
385  bool force)
386 {
387  enum m0_storage_dev_type type = dev->isd_type;
388  unsigned long long cid = (unsigned long long)dev->isd_cid;
389  char *cfg = NULL;
390  char *cfg_init = NULL;
391  char *location;
392  int len;
393  int rc;
394 
396  dev->isd_filename != NULL));
399 
400  switch (type) {
402  len = snprintf(NULL, 0, "linuxstob:%s", dev->isd_filename);
403  location = len > 0 ? m0_alloc(len + 1) : NULL;
404  if (location == NULL)
405  return len < 0 ? M0_ERR(len) : M0_ERR(-ENOMEM);
406  rc = snprintf(location, len + 1, "linuxstob:%s",
407  dev->isd_filename);
408  cfg_init = devs->sds_use_directio ? "directio=true" :
409  "directio=false";
410  M0_ASSERT_INFO(rc == len, "rc=%d", rc);
411  break;
413  len = snprintf(NULL, 0, "adstob:%llu", cid);
414  location = len > 0 ? m0_alloc(len + 1) : NULL;
415  if (location == NULL)
416  return len < 0 ? M0_ERR(len) : M0_ERR(-ENOMEM);
417  rc = snprintf(location, len + 1, "adstob:%llu", cid);
418  M0_ASSERT_INFO(rc == len, "rc=%d", rc);
419  m0_stob_ad_cfg_make(&cfg, devs->sds_be_seg,
420  m0_stob_id_get(dev->isd_stob), size);
421  m0_stob_ad_init_cfg_make(&cfg_init,
422  devs->sds_be_seg->bs_domain);
423  if (cfg == NULL || cfg_init == NULL) {
424  m0_free(location);
425  m0_free(cfg_init);
426  m0_free(cfg);
427  return M0_ERR(-ENOMEM);
428  }
429  break;
430  default:
431  M0_IMPOSSIBLE("Unknown m0_storage_dev type.");
432  };
433 
434  rc = m0_stob_domain_init(location, cfg_init, &dev->isd_domain);
435  if (force && rc == 0) {
437  if (rc != 0)
438  goto out_free;
439  }
440  if (force || rc != 0)
441  rc = m0_stob_domain_create(location, cfg_init, cid, cfg,
442  &dev->isd_domain);
443 out_free:
444  m0_free(location);
446  m0_free(cfg_init);
447  m0_free(cfg);
448 
449  return M0_RC(rc);
450 }
451 
452 static void storage_dev_release(struct m0_ref *ref)
453 {
454  struct m0_storage_dev *dev =
455  container_of(ref, struct m0_storage_dev, isd_ref);
456 
457  M0_ENTRY("dev=%p", dev);
458 
459  storage_dev_tlink_del_fini(dev);
462 
463  M0_LEAVE();
464 }
465 
466 M0_INTERNAL void m0_storage_dev_get(struct m0_storage_dev *dev)
467 {
468  m0_ref_get(&dev->isd_ref);
469 }
470 
471 M0_INTERNAL void m0_storage_dev_put(struct m0_storage_dev *dev)
472 {
473  m0_ref_put(&dev->isd_ref);
474 }
475 
476 static int storage_dev_new(struct m0_storage_devs *devs,
477  uint64_t cid,
478  bool fi_no_dev,
479  const char *path_orig,
480  uint64_t size,
481  struct m0_conf_sdev *conf_sdev,
482  bool force,
483  struct m0_storage_dev **out)
484 {
485  enum m0_storage_dev_type type = devs->sds_type;
486  struct m0_storage_dev *device;
487  struct m0_conf_service *conf_service;
488  struct m0_conf_obj *srv_obj;
489  struct m0_stob_id stob_id;
490  struct m0_stob *stob;
491  const char *path = fi_no_dev ? NULL : path_orig;
492  int rc;
493 
494  M0_ENTRY("cid=%"PRIu64, cid);
496  M0_PRE(ergo(type == M0_STORAGE_DEV_TYPE_LINUX, path_orig != NULL));
497 
498  M0_ALLOC_PTR(device);
499  if (device == NULL)
500  return M0_ERR(-ENOMEM);
501 
502  if (path_orig != NULL) {
503  device->isd_filename = m0_strdup(path_orig);
504  if (device->isd_filename == NULL) {
505  m0_free(device);
506  return M0_ERR(-ENOMEM);
507  }
508  }
510  device->isd_type = type;
511  device->isd_cid = cid;
512  device->isd_stob = NULL;
513 
514  if (type == M0_STORAGE_DEV_TYPE_AD) {
515  m0_stob_id_make(0, cid, &devs->sds_back_domain->sd_id, &stob_id);
516  rc = m0_stob_find(&stob_id, &stob);
517  if (rc != 0)
518  goto end;
519 
522  if (rc != 0)
523  goto stob_put;
524  }
525  if (m0_stob_state_get(stob) == CSS_NOENT) {
526  rc = m0_stob_create(stob, NULL, path);
527  if (rc != 0)
528  goto stob_put;
529  }
530  device->isd_stob = stob;
531  }
532 
533  rc = stob_domain_create_or_init(device, devs, size, force);
534  M0_ASSERT(ergo(rc == 0, device->isd_domain != NULL));
535  if (rc == 0) {
536  if (M0_FI_ENABLED("ad_domain_locate_fail")) {
538  M0_ASSERT(conf_sdev != NULL);
539  m0_confc_close(&conf_sdev->sd_obj);
540  rc = M0_ERR(-EINVAL);
541  } else if (conf_sdev != NULL) {
542  if (type == M0_STORAGE_DEV_TYPE_AD &&
543  m0_fid_validate_linuxstob(&stob_id))
545  &conf_sdev->sd_obj.co_id);
546  m0_conf_obj_get_lock(&conf_sdev->sd_obj);
547  srv_obj = m0_conf_obj_grandparent(&conf_sdev->sd_obj);
548  conf_service = M0_CONF_CAST(srv_obj, m0_conf_service);
550  &conf_sdev->sd_obj.co_ha_chan);
551  device->isd_srv_type = conf_service->cs_type;
552  }
553  }
554 stob_put:
555  if (type == M0_STORAGE_DEV_TYPE_AD) {
556  /* Release reference, taken by m0_stob_find(). */
557  m0_stob_put(stob);
558  }
559 end:
560  if (rc == 0) {
563  &device->isd_detached_lock);
564  *out = device;
565  } else {
566  m0_free(M0_MEMBER(device, isd_filename));
567  m0_free(device);
568  }
569  return rc == 0 ? M0_RC(0) :
570  M0_ERR_INFO(rc, "path_orig=%s cid=%" PRIu64 " conf_sdev="FID_F,
571  path_orig, cid,
572  FID_P(conf_sdev == NULL ? &M0_FID0 :
573  &conf_sdev->sd_obj.co_id));
574 }
575 
576 M0_INTERNAL int m0_storage_dev_new(struct m0_storage_devs *devs,
577  uint64_t cid,
578  const char *path,
579  uint64_t size,
580  struct m0_conf_sdev *conf_sdev,
581  bool force,
582  struct m0_storage_dev **dev)
583 {
584  M0_ENTRY();
585  return M0_RC(storage_dev_new(devs, cid,
586  M0_FI_ENABLED("no_real_dev"), path,
587  size, conf_sdev, force, dev));
588 }
589 
590 M0_INTERNAL int m0_storage_dev_new_by_conf(struct m0_storage_devs *devs,
591  struct m0_conf_sdev *sdev,
592  bool force,
593  struct m0_storage_dev **dev)
594 {
595  M0_ENTRY();
596  return M0_RC(storage_dev_new(devs, sdev->sd_dev_idx,
597  M0_FI_ENABLED("no_real_dev"),
598  sdev->sd_filename, sdev->sd_size,
599  M0_FI_ENABLED("no-conf-dev") ? NULL : sdev,
600  force, dev));
601 }
602 
603 M0_INTERNAL void m0_storage_dev_destroy(struct m0_storage_dev *dev)
604 {
605  struct m0_stob *stob;
606  int rc = 0;
607 
608  M0_ENTRY();
609  M0_PRE(m0_ref_read(&dev->isd_ref) == 0);
610 
611  /* Acquire a reference to the backing store for adstob configuration. */
612  if (dev->isd_type == M0_STORAGE_DEV_TYPE_AD)
614 
616 
617  if (dev->isd_type == M0_STORAGE_DEV_TYPE_AD && rc == 0) {
618  /* Destroy backing store. */
621  else
622  m0_stob_put(stob);
623  }
624  if (rc != 0)
625  M0_LOG(M0_ERROR, "Failed to destroy backing store rc=%d", rc);
628  m0_free(dev->isd_filename);
629  m0_free(dev);
630  M0_LEAVE();
631 }
632 
633 M0_INTERNAL void m0_storage_dev_attach(struct m0_storage_dev *dev,
634  struct m0_storage_devs *devs)
635 {
636  M0_ENTRY();
639 
640  M0_LOG(M0_DEBUG, "get: dev=%p, ref=%" PRIi64 " "
641  "state=%d type=%d, %"PRIu64,
642  dev,
643  m0_ref_read(&dev->isd_ref),
644  dev->isd_ha_state,
645  dev->isd_srv_type,
646  dev->isd_cid);
647  m0_storage_dev_get(dev);
648  storage_dev_tlink_init_at_tail(dev, &devs->sds_devices);
649  M0_LEAVE();
650 }
651 
652 M0_INTERNAL void m0_storage_dev_detach(struct m0_storage_dev *dev)
653 {
654  struct m0_conf_obj *obj;
655 
656  M0_ENTRY();
657  if (m0_clink_is_armed(&dev->isd_clink)) {
659  co_ha_chan);
662  }
663  M0_LOG(M0_DEBUG, "put: dev=%p, ref=%" PRIi64 " "
664  "state=%d type=%d, %"PRIu64,
665  dev,
666  m0_ref_read(&dev->isd_ref),
667  dev->isd_ha_state,
668  dev->isd_srv_type,
669  dev->isd_cid);
670  m0_storage_dev_put(dev);
671  M0_LEAVE();
672 }
673 
674 M0_INTERNAL void m0_storage_dev_space(struct m0_storage_dev *dev,
675  struct m0_storage_space *space)
676 {
677  struct m0_balloc *balloc;
678  struct statfs st;
679  int fd = -1;
680  int rc;
681  int rc1;
682 
683  M0_ENTRY();
684  M0_PRE(dev != NULL);
685 
686  switch (dev->isd_type) {
688  balloc = m0_stob_ad_domain2balloc(dev->isd_domain);
689  M0_ASSERT(balloc != NULL);
690  *space = (struct m0_storage_space) {
691 #ifdef __SPARE_SPACE__
693  balloc->cb_sb.bsb_freespare,
694 #else
695  .sds_free_blocks = balloc->cb_sb.bsb_freeblocks,
696 #endif
697  .sds_block_size = balloc->cb_sb.bsb_blocksize,
698  .sds_avail_blocks = balloc->cb_sb.bsb_freeblocks,
699  .sds_total_size = balloc->cb_sb.bsb_totalsize,
700  };
701  break;
704  if (rc == 0) {
705  rc = fstatfs(fd, &st);
706  rc = rc == -1 ? M0_ERR(-errno) : 0;
708  if (rc1 != 0)
709  M0_LOG(M0_ERROR, "m0_stob_linux_domain_fd_put: "
710  "rc=%d", rc1);
711  }
712  if (rc == 0)
713  *space = (struct m0_storage_space) {
714  .sds_free_blocks = st.f_bfree,
715  .sds_block_size = st.f_bsize,
716  .sds_avail_blocks = st.f_bfree,
717  .sds_total_size = st.f_blocks * st.f_bsize
718  };
719  if (rc != 0)
720  M0_LOG(M0_ERROR, "Can't obtain fstatfs, rc=%d", rc);
721 
722  break;
723  default:
724  M0_IMPOSSIBLE("Unknown storage_dev type.");
725  }
726  M0_LEAVE();
727 }
728 
732 };
733 
735 {
736  struct storage_devs_wait *wait =
738 
739  m0_semaphore_up(&wait->sdw_sem);
740  return true;
741 }
742 
743 M0_INTERNAL void m0_storage_devs_detach_all(struct m0_storage_devs *devs)
744 {
745  struct storage_devs_wait wait = {};
746  struct m0_storage_dev *dev;
747  struct m0_clink *clink;
748 
749  M0_ENTRY();
750  m0_semaphore_init(&wait.sdw_sem, 0);
751  clink = &wait.sdw_clink;
752  m0_tl_for(storage_dev, &devs->sds_devices, dev) {
753  M0_SET0(clink);
755  clink->cl_is_oneshot = true;
757 
759 
760  m0_semaphore_down(&wait.sdw_sem);
762  } m0_tl_endfor;
763  m0_semaphore_fini(&wait.sdw_sem);
764  M0_LEAVE();
765 }
766 
767 M0_INTERNAL int m0_storage_dev_format(struct m0_storage_dev *dev,
768  uint64_t cid)
769 {
770  /*
771  * Nothing do for Format command.
772  */
773  return M0_RC(0);
774 }
775 
776 static int sdev_stob_fsync(void *psdev)
777 {
778  struct m0_storage_dev *sdev = (struct m0_storage_dev *)psdev;
779  int fd = -1;
780  int rc;
781  int rc1;
782 
783  M0_ENTRY("sdev=%p", sdev);
784 
785  if (sdev->isd_type == M0_STORAGE_DEV_TYPE_AD) {
786  fd = m0_stob_fd(sdev->isd_stob);
787  rc = fdatasync(fd);
788  rc = rc == 0 ? 0 : M0_ERR_INFO(-errno, "fd=%d", fd);
789  } else {
792  if (rc == 0) {
793  rc = syncfs(fd);
794  rc = rc == 0 ? 0 : M0_ERR_INFO(-errno, "fd=%d", fd);
796  rc = rc ?: rc1;
797  }
798  }
799  return M0_RC(rc);
800 }
801 
802 M0_INTERNAL int m0_storage_devs_fdatasync(struct m0_storage_devs *sdevs)
803 {
805 
806  return M0_PARALLEL_FOR(storage_dev, &sdevs->sds_pool,
807  &sdevs->sds_devices, sdev_stob_fsync);
808 }
809 
810 M0_INTERNAL int m0_storage_dev_stob_create(struct m0_storage_devs *devs,
811  struct m0_stob_id *sid,
812  struct m0_dtx *dtx)
813 {
814  struct m0_stob *stob = NULL;
815  int rc;
816 
817  M0_ENTRY("stob_id="STOB_ID_F, STOB_ID_P(sid));
818 
819  m0_storage_devs_lock(devs);
820  rc = m0_stob_find(sid, &stob);
821  if (rc == 0) {
824  m0_stob_locate(stob) : 0;
825  rc = rc ?: stob->so_state == CSS_NOENT ?
826  m0_stob_create(stob, dtx, NULL) : 0;
828  m0_stob_dom_get(stob)) != NULL);
829  m0_stob_put(stob);
830  }
832 
833  return M0_RC(rc);
834 }
835 
836 M0_INTERNAL int m0_storage_dev_stob_destroy(struct m0_storage_devs *devs,
837  struct m0_stob *stob,
838  struct m0_dtx *dtx)
839 {
840  struct m0_stob_domain *dom;
841  struct m0_storage_dev *dev;
842  int rc;
843 
844  M0_ENTRY("stob=%p stob_id="STOB_ID_F,
847 
848  m0_storage_devs_lock(devs);
850  rc = m0_stob_destroy(stob, dtx);
851  if (rc == 0) {
852  dev = m0_storage_devs_find_by_dom(devs, dom);
853  M0_ASSERT(dev != NULL);
854  M0_LOG(M0_DEBUG, "put: dev=%p, ref=%" PRIi64 " "
855  "state=%d type=%d, %"PRIu64,
856  dev,
857  m0_ref_read(&dev->isd_ref),
858  dev->isd_ha_state,
859  dev->isd_srv_type,
860  dev->isd_cid);
861  m0_storage_dev_put(dev);
862  }
864 
865  return M0_RC(rc);
866 }
867 
868 M0_INTERNAL int m0_storage_dev_stob_find(struct m0_storage_devs *devs,
869  struct m0_stob_id *sid,
870  struct m0_stob **stob)
871 {
872  struct m0_stob_domain *dom;
873  struct m0_storage_dev *dev;
874  struct m0_stob *stob2 = NULL;
875  enum m0_stob_state stob_state;
876  int rc;
877 
878  M0_ENTRY("stob_id="STOB_ID_F, STOB_ID_P(sid));
879 
880  m0_storage_devs_lock(devs);
881  rc = m0_stob_find(sid, &stob2);
882  if (rc == 0) {
883  stob_state = m0_stob_state_get(stob2);
884  if (stob_state == CSS_DELETE)
885  rc = -ENOENT;
886  else if (stob_state == CSS_UNKNOWN)
887  rc = m0_stob_locate(stob2);
888  if (rc != 0)
889  m0_stob_put(stob2);
890  }
891  if (rc == 0) {
892  dom = m0_stob_dom_get(stob2);
893  dev = m0_storage_devs_find_by_dom(devs, dom);
894  M0_ASSERT(dev != NULL);
895  M0_LOG(M0_DEBUG, "get: dev=%p, ref=%" PRIi64 " "
896  "state=%d type=%d, %"PRIu64,
897  dev,
898  m0_ref_read(&dev->isd_ref),
899  dev->isd_ha_state,
900  dev->isd_srv_type,
901  dev->isd_cid);
902  m0_storage_dev_get(dev);
903  }
905 
906  if (rc == 0)
907  *stob = stob2;
908 
909  return M0_RC(rc);
910 }
911 
912 M0_INTERNAL void m0_storage_dev_stob_put(struct m0_storage_devs *devs,
913  struct m0_stob *stob)
914 {
915  struct m0_stob_domain *dom;
916  struct m0_storage_dev *dev;
917 
918  M0_ENTRY("stob=%p stob_id="STOB_ID_F,
920 
922  m0_stob_put(stob);
923 
924  m0_storage_devs_lock(devs);
925  dev = m0_storage_devs_find_by_dom(devs, dom);
926  M0_ASSERT(dev != NULL);
927  M0_LOG(M0_DEBUG, "put: dev=%p, ref=%" PRIi64 " "
928  "state=%d type=%d, %"PRIu64,
929  dev,
930  m0_ref_read(&dev->isd_ref),
931  dev->isd_ha_state,
932  dev->isd_srv_type,
933  dev->isd_cid);
934  m0_storage_dev_put(dev);
936 
937  M0_LEAVE();
938 }
939 
940 #undef M0_TRACE_SUBSYSTEM
941 
943 /*
944  * Local variables:
945  * c-indentation-style: "K&R"
946  * c-basic-offset: 8
947  * tab-width: 8
948  * fill-column: 80
949  * scroll-step: 1
950  * End:
951  */
const char * sd_filename
Definition: obj.h:649
struct m0_fid co_id
Definition: obj.h:208
M0_TL_DEFINE(storage_dev, M0_INTERNAL, struct m0_storage_dev)
Definition: beck.c:235
M0_INTERNAL struct m0_stob_domain * m0_stob_dom_get(struct m0_stob *stob)
Definition: stob.c:338
M0_INTERNAL struct m0_storage_dev * m0_storage_devs_find_by_cid(struct m0_storage_devs *devs, uint64_t cid)
Definition: storage_dev.c:152
struct m0_be_domain * bs_domain
Definition: seg.h:82
static int stob_domain_create_or_init(struct m0_storage_dev *dev, struct m0_storage_devs *devs, m0_bcount_t size, bool force)
Definition: storage_dev.c:382
#define M0_PRE(cond)
static struct m0_semaphore wait
Definition: item.c:151
Definition: dtm.h:554
struct m0_parallel_pool sds_pool
Definition: storage_dev.h:138
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
Definition: mutex.c:66
m0_bcount_t bsb_freeblocks
Definition: balloc.h:181
#define m0_strdup(s)
Definition: string.h:43
M0_INTERNAL void m0_chan_broadcast_lock(struct m0_chan *chan)
Definition: chan.c:178
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
struct m0_stob * isd_stob
Definition: storage_dev.h:77
M0_INTERNAL int m0_stob_locate(struct m0_stob *stob)
Definition: stob.c:128
m0_bcount_t sds_free_blocks
Definition: storage_dev.h:273
#define ergo(a, b)
Definition: misc.h:293
M0_INTERNAL int m0_storage_dev_stob_find(struct m0_storage_devs *devs, struct m0_stob_id *sid, struct m0_stob **stob)
Definition: storage_dev.c:868
M0_INTERNAL void m0_storage_dev_attach(struct m0_storage_dev *dev, struct m0_storage_devs *devs)
Definition: storage_dev.c:633
M0_INTERNAL void m0_storage_dev_stob_put(struct m0_storage_devs *devs, struct m0_stob *stob)
Definition: storage_dev.c:912
struct m0_chan rh_conf_cache_ready_async
Definition: reqh.h:227
M0_INTERNAL struct m0_conf_obj * m0_conf_cache_lookup(const struct m0_conf_cache *cache, const struct m0_fid *id)
Definition: cache.c:106
#define M0_LOG(level,...)
Definition: trace.h:167
M0_LEAVE()
const struct m0_conf_obj_type * m0_conf_fid_type(const struct m0_fid *fid)
Definition: obj.c:368
M0_INTERNAL void m0_storage_dev_get(struct m0_storage_dev *dev)
Definition: storage_dev.c:466
M0_INTERNAL int m0_stob_domain_destroy(struct m0_stob_domain *dom)
Definition: domain.c:227
m0_bcount_t bsb_totalsize
Definition: balloc.h:180
struct m0_stob_domain * isd_domain
Definition: storage_dev.h:79
static bool storage_devs_conf_expired_cb(struct m0_clink *link)
Definition: storage_dev.c:207
const struct m0_conf_obj_type M0_CONF_SDEV_TYPE
Definition: sdev.c:122
#define M0_MEMBER(ptr, member)
Definition: misc.h:329
enum m0_ha_obj_state isd_ha_state
Definition: storage_dev.h:92
struct m0_semaphore sdw_sem
Definition: storage_dev.c:731
#define M0_PARALLEL_FOR(name, pool, list, process)
Definition: thread_pool.h:116
static void dev_filename_update(struct m0_storage_dev *dev, const struct m0_conf_obj *obj)
Definition: storage_dev.c:193
M0_INTERNAL bool m0_clink_is_armed(const struct m0_clink *link)
Definition: chan.c:303
static bool storage_devs_conf_ready_async_cb(struct m0_clink *link)
Definition: storage_dev.c:335
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL bool m0_fid_validate_linuxstob(const struct m0_stob_id *stob_id)
Definition: fid_convert.c:103
static bool storage_devs_detached_cb(struct m0_clink *clink)
Definition: storage_dev.c:734
#define container_of(ptr, type, member)
Definition: misc.h:33
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
Definition: mutex.c:49
struct m0_stob_domain * sds_back_domain
Definition: storage_dev.h:134
M0_INTERNAL bool m0_fid_is_set(const struct m0_fid *fid)
Definition: fid.c:106
M0_INTERNAL void m0_stob_ad_init_cfg_make(char **str, struct m0_be_domain *dom)
Definition: ad.c:212
static struct foo * obj
Definition: tlist.c:302
#define PRIx64
Definition: types.h:61
const char * location
Definition: storage.c:50
M0_INTERNAL void m0_storage_devs_use_directio(struct m0_storage_devs *devs, bool directio)
Definition: storage_dev.c:134
static struct m0_pools_common pc
Definition: iter_ut.c:59
enum m0_storage_dev_type sds_type
Definition: storage_dev.h:128
#define m0_tl_endfor
Definition: tlist.h:700
struct m0_ref isd_ref
Definition: storage_dev.h:101
return M0_RC(rc)
struct m0_tl sds_devices
Definition: storage_dev.h:132
#define equi(a, b)
Definition: misc.h:297
M0_INTERNAL int m0_storage_dev_new_by_conf(struct m0_storage_devs *devs, struct m0_conf_sdev *sdev, bool force, struct m0_storage_dev **dev)
Definition: storage_dev.c:590
#define M0_ASSERT_EX(cond)
#define M0_ENTRY(...)
Definition: trace.h:170
struct m0_mutex sds_lock
Definition: storage_dev.h:130
M0_INTERNAL void m0_parallel_pool_fini(struct m0_parallel_pool *pool)
Definition: thread_pool.c:204
static int sdev_stob_fsync(void *psdev)
Definition: storage_dev.c:776
uint32_t sd_dev_idx
Definition: obj.h:635
M0_TL_DESCR_DEFINE(storage_dev, "storage_dev", M0_INTERNAL, struct m0_storage_dev, isd_linkage, isd_magic, M0_STORAGE_DEV_MAGIC, M0_STORAGE_DEV_HEAD_MAGIC)
M0_INTERNAL int m0_stob_domain_create(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
Definition: domain.c:217
#define PRIu64
Definition: types.h:58
M0_INTERNAL int m0_storage_dev_new(struct m0_storage_devs *devs, uint64_t cid, const char *path, uint64_t size, struct m0_conf_sdev *conf_sdev, bool force, struct m0_storage_dev **dev)
Definition: storage_dev.c:576
M0_INTERNAL void m0_ref_put(struct m0_ref *ref)
Definition: refs.c:38
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
Definition: refs.c:24
return M0_ERR(-EOPNOTSUPP)
M0_INTERNAL void m0_ref_get(struct m0_ref *ref)
Definition: refs.c:32
M0_INTERNAL struct m0_confc * m0_reqh2confc(struct m0_reqh *reqh)
Definition: reqh.c:753
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
Definition: refs.h:34
M0_INTERNAL const struct m0_stob_id * m0_stob_id_get(struct m0_stob *stob)
Definition: stob.c:250
M0_INTERNAL void m0_storage_devs_lock(struct m0_storage_devs *devs)
Definition: storage_dev.c:71
Definition: stob.h:163
enum m0_stob_state so_state
Definition: stob.h:167
static struct m0_stob * stob
Definition: storage.c:39
#define m0_free0(pptr)
Definition: memory.h:77
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
Definition: chan.c:96
#define M0_ASSERT(cond)
static void stob_put(void)
Definition: storage.c:69
struct m0_clink isd_clink
Definition: storage_dev.h:88
static struct m0_confc * confc
Definition: file.c:94
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
Definition: mutex.c:95
M0_INTERNAL void m0_storage_dev_clink_add(struct m0_clink *link, struct m0_chan *chan)
Definition: storage_dev.c:169
#define STOB_ID_P(si)
Definition: stob.h:109
static struct m0_be_seg * be_seg
Definition: extmap.c:48
M0_INTERNAL int m0_storage_dev_stob_destroy(struct m0_storage_devs *devs, struct m0_stob *stob, struct m0_dtx *dtx)
Definition: storage_dev.c:836
static void storage_devs_conf_refresh(struct m0_storage_devs *storage_devs, struct m0_reqh *reqh)
Definition: storage_dev.c:303
struct m0_conf_obj * m0_conf_obj_grandparent(const struct m0_conf_obj *obj)
Definition: obj.c:384
enum m0_ha_obj_state co_ha_state
Definition: obj.h:241
uint32_t pc_nr_devices
Definition: pool.h:196
#define m0_streq(a, b)
Definition: string.h:34
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL void m0_stob_id_make(uint64_t container, uint64_t key, const struct m0_fid *dom_id, struct m0_stob_id *stob_id)
Definition: stob.c:343
struct m0_conf_cache cc_cache
Definition: confc.h:394
struct m0_mutex isd_detached_lock
Definition: storage_dev.h:107
M0_INTERNAL int m0_parallel_pool_init(struct m0_parallel_pool *pool, int thread_nr, int qlinks_nr)
Definition: thread_pool.c:189
M0_INTERNAL int m0_semaphore_init(struct m0_semaphore *semaphore, unsigned value)
Definition: semaphore.c:38
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
struct m0_chan co_ha_chan
Definition: obj.h:248
Definition: reqh.h:94
M0_INTERNAL void m0_clink_cleanup(struct m0_clink *link)
Definition: chan.c:310
enum m0_conf_service_type isd_srv_type
Definition: storage_dev.h:94
Definition: chan.h:229
M0_INTERNAL int m0_stob_linux_domain_fd_put(struct m0_stob_domain *dom, int fd)
Definition: linux.c:621
m0_bcount_t bsb_blocksize
Definition: balloc.h:186
enum m0_conf_service_type cs_type
Definition: obj.h:598
M0_INTERNAL void m0_storage_devs_fini(struct m0_storage_devs *devs)
Definition: storage_dev.c:107
uint64_t sd_size
Definition: obj.h:643
#define M0_CONF_CAST(ptr, type)
Definition: obj.h:780
struct m0_pool_device_to_service * pc_dev2svc
Definition: pool.h:207
static struct m0_clink clink[RDWR_REQUEST_MAX]
Definition: seg.h:66
M0_INTERNAL int m0_stob_linux_domain_fd_get(struct m0_stob_domain *dom, int *fd)
Definition: linux.c:604
struct m0_fid pds_sdev_fid
Definition: pool.h:77
#define FID_P(f)
Definition: fid.h:77
M0_INTERNAL int m0_storage_dev_format(struct m0_storage_dev *dev, uint64_t cid)
Definition: storage_dev.c:767
enum m0_storage_dev_type isd_type
Definition: storage_dev.h:75
M0_INTERNAL struct m0_storage_dev * m0_storage_devs_find_by_dom(struct m0_storage_devs *devs, struct m0_stob_domain *dom)
Definition: storage_dev.c:161
M0_INTERNAL void m0_parallel_pool_terminate_wait(struct m0_parallel_pool *pool)
Definition: thread_pool.c:247
M0_INTERNAL void m0_storage_devs_detach_all(struct m0_storage_devs *devs)
Definition: storage_dev.c:743
M0_INTERNAL void m0_conf_obj_get_lock(struct m0_conf_obj *obj)
Definition: obj_ops.c:198
struct m0_be_seg * sds_be_seg
Definition: storage_dev.h:136
static void storage_dev_release(struct m0_ref *ref)
Definition: storage_dev.c:452
M0_INTERNAL int m0_storage_devs_init(struct m0_storage_devs *devs, enum m0_storage_dev_type type, struct m0_be_seg *be_seg, struct m0_stob_domain *bstore_dom, struct m0_reqh *reqh)
Definition: storage_dev.c:83
M0_INTERNAL void m0_stob_domain_fini(struct m0_stob_domain *dom)
Definition: domain.c:204
struct m0_clink sds_conf_exp
Definition: storage_dev.h:147
M0_INTERNAL int m0_conf_device_cid_to_fid(struct m0_confc *confc, uint64_t cid, struct m0_fid *fid)
Definition: helpers.c:100
M0_INTERNAL void m0_storage_dev_destroy(struct m0_storage_dev *dev)
Definition: storage_dev.c:603
M0_INTERNAL int m0_stob_create(struct m0_stob *stob, struct m0_dtx *dtx, const char *str_cfg)
Definition: stob.c:154
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:255
struct m0_fid sd_id
Definition: domain.h:96
M0_INTERNAL int m0_stob_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
Definition: stob.c:200
M0_INTERNAL int64_t m0_ref_read(const struct m0_ref *ref)
Definition: refs.c:44
M0_INTERNAL enum m0_stob_state m0_stob_state_get(struct m0_stob *stob)
Definition: stob.c:265
struct m0_reqh reqh
Definition: rm_foms.c:48
Definition: stob.h:91
M0_INTERNAL void m0_storage_devs_locks_disable(struct m0_storage_devs *devs)
Definition: storage_dev.c:145
M0_INTERNAL int m0_stob_domain_init(const char *location, const char *str_cfg_init, struct m0_stob_domain **out)
Definition: domain.c:195
static struct m0_chan chan[RDWR_REQUEST_MAX]
M0_INTERNAL void m0_storage_dev_detach(struct m0_storage_dev *dev)
Definition: storage_dev.c:652
#define M0_FI_ENABLED(tag)
Definition: finject.h:231
Definition: fid.h:38
M0_INTERNAL void m0_storage_dev_space(struct m0_storage_dev *dev, struct m0_storage_space *space)
Definition: storage_dev.c:674
struct m0_chan rh_conf_cache_exp
Definition: reqh.h:194
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_INTERNAL int m0_storage_dev_stob_create(struct m0_storage_devs *devs, struct m0_stob_id *sid, struct m0_dtx *dtx)
Definition: storage_dev.c:810
M0_INTERNAL void m0_semaphore_fini(struct m0_semaphore *semaphore)
Definition: semaphore.c:45
M0_INTERNAL int m0_stob_fd(struct m0_stob *stob)
Definition: stob.c:360
struct m0_clink sdw_clink
Definition: storage_dev.c:730
#define PRIi64
Definition: types.h:59
m0_stob_state
Definition: stob.h:81
struct m0_conf_obj sd_obj
Definition: obj.h:616
m0_bcount_t size
Definition: di.c:39
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
struct m0_pools_common * rh_pools
Definition: reqh.h:118
M0_INTERNAL struct m0_balloc * m0_stob_ad_domain2balloc(const struct m0_stob_domain *dom)
Definition: ad.c:179
static int storage_dev_update_by_conf(struct m0_storage_dev *dev, struct m0_conf_sdev *sdev, struct m0_storage_devs *storage_devs)
Definition: storage_dev.c:277
struct m0_chan isd_detached_chan
Definition: storage_dev.h:106
M0_INTERNAL bool m0_stob_linux_domain_directio(struct m0_stob_domain *dom)
Definition: linux.c:628
struct m0t1fs_filedata * fd
Definition: dir.c:1030
M0_INTERNAL void m0_storage_devs_unlock(struct m0_storage_devs *devs)
Definition: storage_dev.c:77
M0_INTERNAL int m0_stob_find(const struct m0_stob_id *id, struct m0_stob **out)
Definition: stob.c:92
M0_INTERNAL void m0_confc_close(struct m0_conf_obj *obj)
Definition: confc.c:921
M0_INTERNAL void m0_storage_dev_put(struct m0_storage_dev *dev)
Definition: storage_dev.c:471
struct m0_balloc_super_block cb_sb
Definition: balloc.h:227
#define M0_ASSERT_INFO(cond, fmt,...)
uint64_t isd_cid
Definition: storage_dev.h:81
#define STOB_ID_F
Definition: stob.h:108
M0_INTERNAL void m0_semaphore_down(struct m0_semaphore *semaphore)
Definition: semaphore.c:49
#define out(...)
Definition: gen.c:41
M0_INTERNAL void m0_stob_ad_cfg_make(char **str, const struct m0_be_seg *seg, const struct m0_stob_id *bstore_id, const m0_bcount_t size)
Definition: ad.c:220
int type
Definition: dir.c:1031
m0_storage_dev_type
Definition: storage_dev.h:65
M0_INTERNAL void m0_semaphore_up(struct m0_semaphore *semaphore)
Definition: semaphore.c:65
#define M0_FID0
Definition: fid.h:93
char * isd_filename
Definition: storage_dev.h:116
M0_INTERNAL void m0_storage_dev_clink_del(struct m0_clink *link)
Definition: storage_dev.c:176
#define m0_tl_find(name, var, head,...)
Definition: tlist.h:757
M0_INTERNAL void m0_stob_linux_conf_sdev_associate(struct m0_stob *stob, const struct m0_fid *conf_sdev)
Definition: linux.c:594
static bool storage_dev_state_update_cb(struct m0_clink *link)
Definition: storage_dev.c:182
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
Definition: chan.c:112
void m0_free(void *data)
Definition: memory.c:146
static int storage_dev_new(struct m0_storage_devs *devs, uint64_t cid, bool fi_no_dev, const char *path_orig, uint64_t size, struct m0_conf_sdev *conf_sdev, bool force, struct m0_storage_dev **out)
Definition: storage_dev.c:476
M0_INTERNAL int m0_storage_devs_fdatasync(struct m0_storage_devs *sdevs)
Definition: storage_dev.c:802
int32_t rc
Definition: trigger_fop.h:47
M0_INTERNAL bool m0_conf_obj_invariant(const struct m0_conf_obj *obj)
Definition: obj_ops.c:52
struct m0_clink sds_conf_ready_async
Definition: storage_dev.h:149
M0_INTERNAL void m0_stob_put(struct m0_stob *stob)
Definition: stob.c:291
#define FID_F
Definition: fid.h:75
bool sds_locks_disabled
Definition: storage_dev.h:151
#define M0_IMPOSSIBLE(fmt,...)
static bool storage_devs_is_locked(const struct m0_storage_devs *devs)
Definition: storage_dev.c:66