34 #include <linux/string.h>
37 #include <linux/random.h>
38 #include <linux/module.h>
40 #include <linux/slab.h>
44 #define EXOFS_DBGMSG2(M...) do {} while (0)
90 memset(opts, 0,
sizeof(*opts));
91 opts->
timeout = BLK_DEFAULT_SG_TIMEOUT;
134 EXOFS_ERR(
"Need to specify the following options:\n");
175 static void exofs_destroy_inode(
struct inode *inode)
183 static void exofs_init_once(
void *
foo)
193 static int init_inodecache(
void)
199 if (exofs_inode_cachep ==
NULL)
207 static void destroy_inodecache(
void)
233 EXOFS_DBGMSG(
"%s: osd_start_request failed.\n", __func__);
238 EXOFS_DBGMSG(
"%s: osd_req_read_kern failed.\n", __func__);
244 EXOFS_DBGMSG(
"Failed to osd_finalize_request() => %d\n", ret);
256 "length=0x%llx dev=%p ret=>%d\n",
269 [0] = g_attr_sb_stats,
276 EXOFS_ERR(
"%s: ore_get_io_state failed.\n", __func__);
285 EXOFS_ERR(
"Error reading super_block stats => %d\n", ret);
291 EXOFS_ERR(
"%s: extract_attr of sb_stats failed\n", __func__);
297 if (
unlikely(attrs[0].len !=
sizeof(*ess))) {
298 EXOFS_ERR(
"%s: Wrong version of exofs_sb_stats "
299 "size(%d) != expected(%zd)\n",
300 __func__, attrs[0].len,
sizeof(*ess));
314 static void stats_done(
struct ore_io_state *ios,
void *p)
324 [0] = g_attr_sb_stats,
331 EXOFS_ERR(
"%s: ore_get_io_state failed.\n", __func__);
340 ios->
done = stats_done;
347 EXOFS_ERR(
"%s: ore_write failed.\n", __func__);
405 EXOFS_ERR(
"%s: ore_write failed.\n", __func__);
414 static void _exofs_print_device(
const char *
msg,
const char *dev_path,
425 unsigned numdevs = sbi->
oc.numdevs;
428 unsigned i = --numdevs;
429 struct osd_dev *od = ore_comp_dev(&sbi->
oc, i);
432 ore_comp_set_dev(&sbi->
oc, i,
NULL);
444 static void exofs_put_super(
struct super_block *sb)
463 _exofs_print_device(
"Unmounting",
NULL, ore_comp_dev(&sbi->
oc, 0),
472 static int _read_and_match_data_map(
struct exofs_sb_info *sbi,
unsigned numdevs,
485 sbi->
layout.raid_algorithm =
491 "num_comps=%u stripe_unit=0x%x group_width=%u "
492 "group_depth=0x%llx mirrors_p1=%u raid_algorithm=%u\n",
498 sbi->
layout.raid_algorithm);
504 const unsigned _MIN_RA = 32;
510 if (ra_pages < _MIN_RA)
511 ra_pages =
roundup(_MIN_RA, ra_pages / 2);
513 if (ra_pages > max_io_pages)
514 ra_pages = max_io_pages;
549 struct __alloc_ore_devs_and_exofs_devs {
553 struct ore_dev *oreds[numdevs * 2 - 1];
561 EXOFS_ERR(
"ERROR: failed allocating Device array[%d]\n",
566 sbi->
oc.ods = aoded->oreds;
567 *peds = eds = aoded->eds;
568 for (i = 0; i < numdevs; ++
i)
569 aoded->oreds[i] = &eds[i].
ored;
573 static int exofs_read_lookup_dev_table(
struct exofs_sb_info *sbi,
575 unsigned table_count)
580 unsigned table_bytes = table_count *
sizeof(dt->
dt_dev_table[0]) +
587 EXOFS_ERR(
"ERROR: allocating %x bytes for device table\n",
594 comp.obj.partition = sbi->
one_comp.obj.partition;
598 ret = exofs_read_kern(fscb_od, comp.cred, &comp.obj, 0, dt,
601 EXOFS_ERR(
"ERROR: reading device table\n");
610 WARN_ON(table_count != numdevs);
612 ret = _read_and_match_data_map(sbi, numdevs, dt);
624 memcpy(&sbi->
oc.ods[numdevs], &sbi->
oc.ods[0],
625 (numdevs - 1) *
sizeof(sbi->
oc.ods[0]));
633 for (i = 0; i < numdevs; i++) {
639 EXOFS_ERR(
"ERROR: Read all-zeros device entry\n");
655 eds[
i].
ored.od = fscb_od;
665 EXOFS_ERR(
"ERROR: device requested is not found "
666 "osd_name-%s =>%d\n", odi.
osdname, ret);
676 ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb,
679 EXOFS_ERR(
"ERROR: Malformed participating device "
680 "error reading fscb osd_name-%s\n",
695 EXOFS_ERR(
"ERROR: Bad device-table container device not present\n");
705 static int exofs_fill_super(
struct super_block *sb,
void *
data,
int silent)
713 unsigned table_count;
739 sbi->
layout.mirrors_p1 = 1;
740 sbi->
layout.group_width = 1;
741 sbi->
layout.group_depth = -1;
742 sbi->
layout.group_count = 1;
748 sbi->
oc.single_comp = EC_SINGLE_COMP;
762 comp.obj.partition = sbi->
one_comp.obj.partition;
766 ret = exofs_read_kern(od, comp.cred, &comp.obj, 0, &fscb,
sizeof(fscb));
783 EXOFS_ERR(
"ERROR: Bad FSCB version expected-%d got-%d\n",
795 ret = exofs_read_lookup_dev_table(sbi, od, table_count);
805 ore_comp_set_dev(&sbi->
oc, 0, od);
809 __sbi_read_stats(sbi);
812 sbi->
bdi.ra_pages = __ra_pages(&sbi->
layout);
815 sb->
s_op = &exofs_sops;
825 EXOFS_ERR(
"ERROR: get root inode failed\n");
833 EXOFS_ERR(
"ERROR: corrupt root inode (mode = %hd)\n",
848 _exofs_print_device(
"Mounting", opts->
dev_name,
849 ore_comp_dev(&sbi->
oc, 0),
854 EXOFS_ERR(
"Unable to mount exofs on %s pid=0x%llx err=%d\n",
864 int flags,
const char *dev_name,
870 ret = parse_options(data, &opts);
876 return mount_nodev(type, flags, &opts, exofs_fill_super);
941 .alloc_inode = exofs_alloc_inode,
942 .destroy_inode = exofs_destroy_inode,
945 .put_super = exofs_put_super,
946 .sync_fs = exofs_sync_fs,
947 .statfs = exofs_statfs,
954 static struct dentry *exofs_get_parent(
struct dentry *
child)
964 static struct inode *exofs_nfs_get_inode(
struct super_block *sb,
971 return ERR_CAST(inode);
980 static struct dentry *exofs_fh_to_dentry(
struct super_block *sb,
981 struct fid *
fid,
int fh_len,
int fh_type)
984 exofs_nfs_get_inode);
987 static struct dentry *exofs_fh_to_parent(
struct super_block *sb,
988 struct fid *
fid,
int fh_len,
int fh_type)
991 exofs_nfs_get_inode);
995 .fh_to_dentry = exofs_fh_to_dentry,
996 .fh_to_parent = exofs_fh_to_parent,
997 .get_parent = exofs_get_parent,
1010 .mount = exofs_mount,
1014 static int __init init_exofs(
void)
1018 err = init_inodecache();
1031 destroy_inodecache();
1036 static void __exit exit_exofs(
void)
1040 destroy_inodecache();