57
58
* exofs-specific mount-time options.
59
enum { Opt_pid, Opt_to, Opt_mkfs, Opt_format, Opt_err };
60
enum { Opt_name, Opt_pid, Opt_to, Opt_err };
62
63
* Our mount-time options. These should ideally be 64-bit unsigned, but the
95
97
token = match_token(p, tokens, args);
100
opts->dev_name = match_strdup(&args[0]);
101
if (unlikely(!opts->dev_name)) {
102
EXOFS_ERR("Error allocating dev_name");
105
opts->is_osdname = true;
98
108
if (0 == match_strlcpy(str, &args[0], sizeof(str)))
203
213
static const struct super_operations exofs_sops;
204
214
static const struct export_operations exofs_export_ops;
216
static const struct osd_attr g_attr_sb_stats = ATTR_DEF(
219
sizeof(struct exofs_sb_stats));
221
static int __sbi_read_stats(struct exofs_sb_info *sbi)
223
struct osd_attr attrs[] = {
224
[0] = g_attr_sb_stats,
226
struct exofs_io_state *ios;
229
ret = exofs_get_io_state(&sbi->layout, &ios);
231
EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
235
ios->cred = sbi->s_cred;
237
ios->in_attr = attrs;
238
ios->in_attr_len = ARRAY_SIZE(attrs);
240
ret = exofs_sbi_read(ios);
242
EXOFS_ERR("Error reading super_block stats => %d\n", ret);
246
ret = extract_attr_from_ios(ios, &attrs[0]);
248
EXOFS_ERR("%s: extract_attr of sb_stats failed\n", __func__);
252
struct exofs_sb_stats *ess;
254
if (unlikely(attrs[0].len != sizeof(*ess))) {
255
EXOFS_ERR("%s: Wrong version of exofs_sb_stats "
256
"size(%d) != expected(%zd)\n",
257
__func__, attrs[0].len, sizeof(*ess));
261
ess = attrs[0].val_ptr;
262
sbi->s_nextid = le64_to_cpu(ess->s_nextid);
263
sbi->s_numfiles = le32_to_cpu(ess->s_numfiles);
267
exofs_put_io_state(ios);
271
static void stats_done(struct exofs_io_state *ios, void *p)
273
exofs_put_io_state(ios);
274
/* Good thanks nothing to do anymore */
277
/* Asynchronously write the stats attribute */
278
int exofs_sbi_write_stats(struct exofs_sb_info *sbi)
280
struct osd_attr attrs[] = {
281
[0] = g_attr_sb_stats,
283
struct exofs_io_state *ios;
286
ret = exofs_get_io_state(&sbi->layout, &ios);
288
EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
292
sbi->s_ess.s_nextid = cpu_to_le64(sbi->s_nextid);
293
sbi->s_ess.s_numfiles = cpu_to_le64(sbi->s_numfiles);
294
attrs[0].val_ptr = &sbi->s_ess;
296
ios->cred = sbi->s_cred;
297
ios->done = stats_done;
299
ios->out_attr = attrs;
300
ios->out_attr_len = ARRAY_SIZE(attrs);
302
ret = exofs_sbi_write(ios);
304
EXOFS_ERR("%s: exofs_sbi_write failed.\n", __func__);
305
exofs_put_io_state(ios);
207
312
* Write the superblock to the OSD
213
318
struct exofs_io_state *ios;
214
319
int ret = -ENOMEM;
321
fscb = kmalloc(sizeof(*fscb), GFP_KERNEL);
327
/* NOTE: We no longer dirty the super_block anywhere in exofs. The
328
* reason we write the fscb here on unmount is so we can stay backwards
329
* compatible with fscb->s_version == 1. (What we are not compatible
330
* with is if a new version FS crashed and then we try to mount an old
331
* version). Otherwise the exofs_fscb is read-only from mkfs time. All
332
* the writeable info is set in exofs_sbi_write_stats() above.
334
ret = exofs_get_io_state(&sbi->layout, &ios);
220
ret = exofs_get_io_state(&sbi->layout, &ios);
224
/* Note: We only write the changing part of the fscb. .i.e upto the
225
* the fscb->s_dev_table_oid member. There is no read-modify-write
228
340
ios->length = offsetof(struct exofs_fscb, s_dev_table_oid);
229
341
memset(fscb, 0, ios->length);
230
342
fscb->s_nextid = cpu_to_le64(sbi->s_nextid);
293
406
struct exofs_sb_info *sbi = sb->s_fs_info;
296
exofs_write_super(sb);
298
408
/* make sure there are no pending commands */
299
409
for (num_pend = atomic_read(&sbi->s_curr_pending); num_pend > 0;
300
410
num_pend = atomic_read(&sbi->s_curr_pending)) {
301
411
wait_queue_head_t wq;
413
printk(KERN_NOTICE "%s: !!Pending operations in flight. "
414
"This is a BUG. please report to osd-dev@open-osd.org\n",
302
416
init_waitqueue_head(&wq);
303
417
wait_event_timeout(wq,
304
418
(atomic_read(&sbi->s_curr_pending) == 0),
507
static unsigned __ra_pages(struct exofs_layout *layout)
509
const unsigned _MIN_RA = 32; /* min 128K read-ahead */
510
unsigned ra_pages = layout->group_width * layout->stripe_unit /
512
unsigned max_io_pages = exofs_max_io_pages(layout, ~0);
514
ra_pages *= 2; /* two stripes */
515
if (ra_pages < _MIN_RA)
516
ra_pages = roundup(_MIN_RA, ra_pages / 2);
518
if (ra_pages > max_io_pages)
519
ra_pages = max_io_pages;
393
524
/* @odi is valid only as long as @fscb_dev is valid */
394
525
static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev,
395
526
struct osd_dev_info *odi)
560
691
/* use mount options to fill superblock */
561
od = osduld_path_lookup(opts->dev_name);
692
if (opts->is_osdname) {
693
struct osd_dev_info odi = {.systemid_len = 0};
695
odi.osdname_len = strlen(opts->dev_name);
696
odi.osdname = (u8 *)opts->dev_name;
697
od = osduld_info_lookup(&odi);
699
od = osduld_path_lookup(opts->dev_name);
562
701
if (IS_ERR(od)) {
607
if (le32_to_cpu(fscb.s_version) != EXOFS_FSCB_VER) {
747
if (le32_to_cpu(fscb.s_version) > EXOFS_FSCB_VER) {
608
748
EXOFS_ERR("ERROR: Bad FSCB version expected-%d got-%d\n",
609
749
EXOFS_FSCB_VER, le32_to_cpu(fscb.s_version));