super.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /* AFS superblock handling
  2. *
  3. * Copyright (c) 2002, 2007 Red Hat, Inc. All rights reserved.
  4. *
  5. * This software may be freely redistributed under the terms of the
  6. * GNU General Public License.
  7. *
  8. * You should have received a copy of the GNU General Public License
  9. * along with this program; if not, write to the Free Software
  10. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  11. *
  12. * Authors: David Howells <dhowells@redhat.com>
  13. * David Woodhouse <dwmw2@infradead.org>
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/mount.h>
  19. #include <linux/init.h>
  20. #include <linux/slab.h>
  21. #include <linux/fs.h>
  22. #include <linux/pagemap.h>
  23. #include <linux/parser.h>
  24. #include <linux/statfs.h>
  25. #include <linux/sched.h>
  26. #include <linux/nsproxy.h>
  27. #include <linux/magic.h>
  28. #include <net/net_namespace.h>
  29. #include "internal.h"
  30. static void afs_i_init_once(void *foo);
  31. static struct dentry *afs_mount(struct file_system_type *fs_type,
  32. int flags, const char *dev_name, void *data);
  33. static void afs_kill_super(struct super_block *sb);
  34. static struct inode *afs_alloc_inode(struct super_block *sb);
  35. static void afs_destroy_inode(struct inode *inode);
  36. static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
  37. static int afs_show_devname(struct seq_file *m, struct dentry *root);
  38. static int afs_show_options(struct seq_file *m, struct dentry *root);
  39. struct file_system_type afs_fs_type = {
  40. .owner = THIS_MODULE,
  41. .name = "afs",
  42. .mount = afs_mount,
  43. .kill_sb = afs_kill_super,
  44. .fs_flags = 0,
  45. };
  46. MODULE_ALIAS_FS("afs");
  47. int afs_net_id;
  48. static const struct super_operations afs_super_ops = {
  49. .statfs = afs_statfs,
  50. .alloc_inode = afs_alloc_inode,
  51. .drop_inode = afs_drop_inode,
  52. .destroy_inode = afs_destroy_inode,
  53. .evict_inode = afs_evict_inode,
  54. .show_devname = afs_show_devname,
  55. .show_options = afs_show_options,
  56. };
  57. static struct kmem_cache *afs_inode_cachep;
  58. static atomic_t afs_count_active_inodes;
  59. enum {
  60. afs_no_opt,
  61. afs_opt_cell,
  62. afs_opt_dyn,
  63. afs_opt_rwpath,
  64. afs_opt_vol,
  65. afs_opt_autocell,
  66. };
  67. static const match_table_t afs_options_list = {
  68. { afs_opt_cell, "cell=%s" },
  69. { afs_opt_dyn, "dyn" },
  70. { afs_opt_rwpath, "rwpath" },
  71. { afs_opt_vol, "vol=%s" },
  72. { afs_opt_autocell, "autocell" },
  73. { afs_no_opt, NULL },
  74. };
  75. /*
  76. * initialise the filesystem
  77. */
  78. int __init afs_fs_init(void)
  79. {
  80. int ret;
  81. _enter("");
  82. /* create ourselves an inode cache */
  83. atomic_set(&afs_count_active_inodes, 0);
  84. ret = -ENOMEM;
  85. afs_inode_cachep = kmem_cache_create("afs_inode_cache",
  86. sizeof(struct afs_vnode),
  87. 0,
  88. SLAB_HWCACHE_ALIGN|SLAB_ACCOUNT,
  89. afs_i_init_once);
  90. if (!afs_inode_cachep) {
  91. printk(KERN_NOTICE "kAFS: Failed to allocate inode cache\n");
  92. return ret;
  93. }
  94. /* now export our filesystem to lesser mortals */
  95. ret = register_filesystem(&afs_fs_type);
  96. if (ret < 0) {
  97. kmem_cache_destroy(afs_inode_cachep);
  98. _leave(" = %d", ret);
  99. return ret;
  100. }
  101. _leave(" = 0");
  102. return 0;
  103. }
  104. /*
  105. * clean up the filesystem
  106. */
  107. void afs_fs_exit(void)
  108. {
  109. _enter("");
  110. afs_mntpt_kill_timer();
  111. unregister_filesystem(&afs_fs_type);
  112. if (atomic_read(&afs_count_active_inodes) != 0) {
  113. printk("kAFS: %d active inode objects still present\n",
  114. atomic_read(&afs_count_active_inodes));
  115. BUG();
  116. }
  117. /*
  118. * Make sure all delayed rcu free inodes are flushed before we
  119. * destroy cache.
  120. */
  121. rcu_barrier();
  122. kmem_cache_destroy(afs_inode_cachep);
  123. _leave("");
  124. }
  125. /*
  126. * Display the mount device name in /proc/mounts.
  127. */
  128. static int afs_show_devname(struct seq_file *m, struct dentry *root)
  129. {
  130. struct afs_super_info *as = AFS_FS_S(root->d_sb);
  131. struct afs_volume *volume = as->volume;
  132. struct afs_cell *cell = as->cell;
  133. const char *suf = "";
  134. char pref = '%';
  135. if (as->dyn_root) {
  136. seq_puts(m, "none");
  137. return 0;
  138. }
  139. switch (volume->type) {
  140. case AFSVL_RWVOL:
  141. break;
  142. case AFSVL_ROVOL:
  143. pref = '#';
  144. if (volume->type_force)
  145. suf = ".readonly";
  146. break;
  147. case AFSVL_BACKVOL:
  148. pref = '#';
  149. suf = ".backup";
  150. break;
  151. }
  152. seq_printf(m, "%c%s:%s%s", pref, cell->name, volume->name, suf);
  153. return 0;
  154. }
  155. /*
  156. * Display the mount options in /proc/mounts.
  157. */
  158. static int afs_show_options(struct seq_file *m, struct dentry *root)
  159. {
  160. struct afs_super_info *as = AFS_FS_S(root->d_sb);
  161. if (as->dyn_root)
  162. seq_puts(m, ",dyn");
  163. if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
  164. seq_puts(m, ",autocell");
  165. return 0;
  166. }
  167. /*
  168. * parse the mount options
  169. * - this function has been shamelessly adapted from the ext3 fs which
  170. * shamelessly adapted it from the msdos fs
  171. */
  172. static int afs_parse_options(struct afs_mount_params *params,
  173. char *options, const char **devname)
  174. {
  175. struct afs_cell *cell;
  176. substring_t args[MAX_OPT_ARGS];
  177. char *p;
  178. int token;
  179. _enter("%s", options);
  180. options[PAGE_SIZE - 1] = 0;
  181. while ((p = strsep(&options, ","))) {
  182. if (!*p)
  183. continue;
  184. token = match_token(p, afs_options_list, args);
  185. switch (token) {
  186. case afs_opt_cell:
  187. rcu_read_lock();
  188. cell = afs_lookup_cell_rcu(params->net,
  189. args[0].from,
  190. args[0].to - args[0].from);
  191. rcu_read_unlock();
  192. if (IS_ERR(cell))
  193. return PTR_ERR(cell);
  194. afs_put_cell(params->net, params->cell);
  195. params->cell = cell;
  196. break;
  197. case afs_opt_rwpath:
  198. params->rwpath = true;
  199. break;
  200. case afs_opt_vol:
  201. *devname = args[0].from;
  202. break;
  203. case afs_opt_autocell:
  204. params->autocell = true;
  205. break;
  206. case afs_opt_dyn:
  207. params->dyn_root = true;
  208. break;
  209. default:
  210. printk(KERN_ERR "kAFS:"
  211. " Unknown or invalid mount option: '%s'\n", p);
  212. return -EINVAL;
  213. }
  214. }
  215. _leave(" = 0");
  216. return 0;
  217. }
  218. /*
  219. * parse a device name to get cell name, volume name, volume type and R/W
  220. * selector
  221. * - this can be one of the following:
  222. * "%[cell:]volume[.]" R/W volume
  223. * "#[cell:]volume[.]" R/O or R/W volume (rwpath=0),
  224. * or R/W (rwpath=1) volume
  225. * "%[cell:]volume.readonly" R/O volume
  226. * "#[cell:]volume.readonly" R/O volume
  227. * "%[cell:]volume.backup" Backup volume
  228. * "#[cell:]volume.backup" Backup volume
  229. */
  230. static int afs_parse_device_name(struct afs_mount_params *params,
  231. const char *name)
  232. {
  233. struct afs_cell *cell;
  234. const char *cellname, *suffix;
  235. int cellnamesz;
  236. _enter(",%s", name);
  237. if (!name) {
  238. printk(KERN_ERR "kAFS: no volume name specified\n");
  239. return -EINVAL;
  240. }
  241. if ((name[0] != '%' && name[0] != '#') || !name[1]) {
  242. printk(KERN_ERR "kAFS: unparsable volume name\n");
  243. return -EINVAL;
  244. }
  245. /* determine the type of volume we're looking for */
  246. params->type = AFSVL_ROVOL;
  247. params->force = false;
  248. if (params->rwpath || name[0] == '%') {
  249. params->type = AFSVL_RWVOL;
  250. params->force = true;
  251. }
  252. name++;
  253. /* split the cell name out if there is one */
  254. params->volname = strchr(name, ':');
  255. if (params->volname) {
  256. cellname = name;
  257. cellnamesz = params->volname - name;
  258. params->volname++;
  259. } else {
  260. params->volname = name;
  261. cellname = NULL;
  262. cellnamesz = 0;
  263. }
  264. /* the volume type is further affected by a possible suffix */
  265. suffix = strrchr(params->volname, '.');
  266. if (suffix) {
  267. if (strcmp(suffix, ".readonly") == 0) {
  268. params->type = AFSVL_ROVOL;
  269. params->force = true;
  270. } else if (strcmp(suffix, ".backup") == 0) {
  271. params->type = AFSVL_BACKVOL;
  272. params->force = true;
  273. } else if (suffix[1] == 0) {
  274. } else {
  275. suffix = NULL;
  276. }
  277. }
  278. params->volnamesz = suffix ?
  279. suffix - params->volname : strlen(params->volname);
  280. _debug("cell %*.*s [%p]",
  281. cellnamesz, cellnamesz, cellname ?: "", params->cell);
  282. /* lookup the cell record */
  283. if (cellname || !params->cell) {
  284. cell = afs_lookup_cell(params->net, cellname, cellnamesz,
  285. NULL, false);
  286. if (IS_ERR(cell)) {
  287. printk(KERN_ERR "kAFS: unable to lookup cell '%*.*s'\n",
  288. cellnamesz, cellnamesz, cellname ?: "");
  289. return PTR_ERR(cell);
  290. }
  291. afs_put_cell(params->net, params->cell);
  292. params->cell = cell;
  293. }
  294. _debug("CELL:%s [%p] VOLUME:%*.*s SUFFIX:%s TYPE:%d%s",
  295. params->cell->name, params->cell,
  296. params->volnamesz, params->volnamesz, params->volname,
  297. suffix ?: "-", params->type, params->force ? " FORCE" : "");
  298. return 0;
  299. }
  300. /*
  301. * check a superblock to see if it's the one we're looking for
  302. */
  303. static int afs_test_super(struct super_block *sb, void *data)
  304. {
  305. struct afs_super_info *as1 = data;
  306. struct afs_super_info *as = AFS_FS_S(sb);
  307. return (as->net_ns == as1->net_ns &&
  308. as->volume &&
  309. as->volume->vid == as1->volume->vid &&
  310. as->cell == as1->cell &&
  311. !as->dyn_root);
  312. }
  313. static int afs_dynroot_test_super(struct super_block *sb, void *data)
  314. {
  315. struct afs_super_info *as1 = data;
  316. struct afs_super_info *as = AFS_FS_S(sb);
  317. return (as->net_ns == as1->net_ns &&
  318. as->dyn_root);
  319. }
  320. static int afs_set_super(struct super_block *sb, void *data)
  321. {
  322. struct afs_super_info *as = data;
  323. sb->s_fs_info = as;
  324. return set_anon_super(sb, NULL);
  325. }
  326. /*
  327. * fill in the superblock
  328. */
  329. static int afs_fill_super(struct super_block *sb,
  330. struct afs_mount_params *params)
  331. {
  332. struct afs_super_info *as = AFS_FS_S(sb);
  333. struct afs_fid fid;
  334. struct inode *inode = NULL;
  335. int ret;
  336. _enter("");
  337. /* fill in the superblock */
  338. sb->s_blocksize = PAGE_SIZE;
  339. sb->s_blocksize_bits = PAGE_SHIFT;
  340. sb->s_maxbytes = MAX_LFS_FILESIZE;
  341. sb->s_magic = AFS_FS_MAGIC;
  342. sb->s_op = &afs_super_ops;
  343. if (!as->dyn_root)
  344. sb->s_xattr = afs_xattr_handlers;
  345. ret = super_setup_bdi(sb);
  346. if (ret)
  347. return ret;
  348. sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
  349. /* allocate the root inode and dentry */
  350. if (as->dyn_root) {
  351. inode = afs_iget_pseudo_dir(sb, true);
  352. } else {
  353. sprintf(sb->s_id, "%u", as->volume->vid);
  354. afs_activate_volume(as->volume);
  355. fid.vid = as->volume->vid;
  356. fid.vnode = 1;
  357. fid.unique = 1;
  358. inode = afs_iget(sb, params->key, &fid, NULL, NULL, NULL);
  359. }
  360. if (IS_ERR(inode))
  361. return PTR_ERR(inode);
  362. if (params->autocell || params->dyn_root)
  363. set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
  364. ret = -ENOMEM;
  365. sb->s_root = d_make_root(inode);
  366. if (!sb->s_root)
  367. goto error;
  368. if (as->dyn_root) {
  369. sb->s_d_op = &afs_dynroot_dentry_operations;
  370. ret = afs_dynroot_populate(sb);
  371. if (ret < 0)
  372. goto error;
  373. } else {
  374. sb->s_d_op = &afs_fs_dentry_operations;
  375. }
  376. _leave(" = 0");
  377. return 0;
  378. error:
  379. _leave(" = %d", ret);
  380. return ret;
  381. }
  382. static struct afs_super_info *afs_alloc_sbi(struct afs_mount_params *params)
  383. {
  384. struct afs_super_info *as;
  385. as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
  386. if (as) {
  387. as->net_ns = get_net(params->net_ns);
  388. if (params->dyn_root)
  389. as->dyn_root = true;
  390. else
  391. as->cell = afs_get_cell(params->cell);
  392. }
  393. return as;
  394. }
  395. static void afs_destroy_sbi(struct afs_super_info *as)
  396. {
  397. if (as) {
  398. afs_put_volume(as->cell, as->volume);
  399. afs_put_cell(afs_net(as->net_ns), as->cell);
  400. put_net(as->net_ns);
  401. kfree(as);
  402. }
  403. }
  404. static void afs_kill_super(struct super_block *sb)
  405. {
  406. struct afs_super_info *as = AFS_FS_S(sb);
  407. struct afs_net *net = afs_net(as->net_ns);
  408. if (as->dyn_root)
  409. afs_dynroot_depopulate(sb);
  410. /* Clear the callback interests (which will do ilookup5) before
  411. * deactivating the superblock.
  412. */
  413. if (as->volume)
  414. afs_clear_callback_interests(net, as->volume->servers);
  415. kill_anon_super(sb);
  416. if (as->volume)
  417. afs_deactivate_volume(as->volume);
  418. afs_destroy_sbi(as);
  419. }
  420. /*
  421. * get an AFS superblock
  422. */
  423. static struct dentry *afs_mount(struct file_system_type *fs_type,
  424. int flags, const char *dev_name, void *options)
  425. {
  426. struct afs_mount_params params;
  427. struct super_block *sb;
  428. struct afs_volume *candidate;
  429. struct key *key;
  430. struct afs_super_info *as;
  431. int ret;
  432. _enter(",,%s,%p", dev_name, options);
  433. memset(&params, 0, sizeof(params));
  434. ret = -EINVAL;
  435. if (current->nsproxy->net_ns != &init_net)
  436. goto error;
  437. params.net_ns = current->nsproxy->net_ns;
  438. params.net = afs_net(params.net_ns);
  439. /* parse the options and device name */
  440. if (options) {
  441. ret = afs_parse_options(&params, options, &dev_name);
  442. if (ret < 0)
  443. goto error;
  444. }
  445. if (!params.dyn_root) {
  446. ret = afs_parse_device_name(&params, dev_name);
  447. if (ret < 0)
  448. goto error;
  449. /* try and do the mount securely */
  450. key = afs_request_key(params.cell);
  451. if (IS_ERR(key)) {
  452. _leave(" = %ld [key]", PTR_ERR(key));
  453. ret = PTR_ERR(key);
  454. goto error;
  455. }
  456. params.key = key;
  457. }
  458. /* allocate a superblock info record */
  459. ret = -ENOMEM;
  460. as = afs_alloc_sbi(&params);
  461. if (!as)
  462. goto error_key;
  463. if (!params.dyn_root) {
  464. /* Assume we're going to need a volume record; at the very
  465. * least we can use it to update the volume record if we have
  466. * one already. This checks that the volume exists within the
  467. * cell.
  468. */
  469. candidate = afs_create_volume(&params);
  470. if (IS_ERR(candidate)) {
  471. ret = PTR_ERR(candidate);
  472. goto error_as;
  473. }
  474. as->volume = candidate;
  475. }
  476. /* allocate a deviceless superblock */
  477. sb = sget(fs_type,
  478. as->dyn_root ? afs_dynroot_test_super : afs_test_super,
  479. afs_set_super, flags, as);
  480. if (IS_ERR(sb)) {
  481. ret = PTR_ERR(sb);
  482. goto error_as;
  483. }
  484. if (!sb->s_root) {
  485. /* initial superblock/root creation */
  486. _debug("create");
  487. ret = afs_fill_super(sb, &params);
  488. if (ret < 0)
  489. goto error_sb;
  490. as = NULL;
  491. sb->s_flags |= SB_ACTIVE;
  492. } else {
  493. _debug("reuse");
  494. ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
  495. afs_destroy_sbi(as);
  496. as = NULL;
  497. }
  498. afs_put_cell(params.net, params.cell);
  499. key_put(params.key);
  500. _leave(" = 0 [%p]", sb);
  501. return dget(sb->s_root);
  502. error_sb:
  503. deactivate_locked_super(sb);
  504. goto error_key;
  505. error_as:
  506. afs_destroy_sbi(as);
  507. error_key:
  508. key_put(params.key);
  509. error:
  510. afs_put_cell(params.net, params.cell);
  511. _leave(" = %d", ret);
  512. return ERR_PTR(ret);
  513. }
  514. /*
  515. * Initialise an inode cache slab element prior to any use. Note that
  516. * afs_alloc_inode() *must* reset anything that could incorrectly leak from one
  517. * inode to another.
  518. */
  519. static void afs_i_init_once(void *_vnode)
  520. {
  521. struct afs_vnode *vnode = _vnode;
  522. memset(vnode, 0, sizeof(*vnode));
  523. inode_init_once(&vnode->vfs_inode);
  524. mutex_init(&vnode->io_lock);
  525. init_rwsem(&vnode->validate_lock);
  526. spin_lock_init(&vnode->wb_lock);
  527. spin_lock_init(&vnode->lock);
  528. INIT_LIST_HEAD(&vnode->wb_keys);
  529. INIT_LIST_HEAD(&vnode->pending_locks);
  530. INIT_LIST_HEAD(&vnode->granted_locks);
  531. INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
  532. seqlock_init(&vnode->cb_lock);
  533. }
  534. /*
  535. * allocate an AFS inode struct from our slab cache
  536. */
  537. static struct inode *afs_alloc_inode(struct super_block *sb)
  538. {
  539. struct afs_vnode *vnode;
  540. vnode = kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
  541. if (!vnode)
  542. return NULL;
  543. atomic_inc(&afs_count_active_inodes);
  544. /* Reset anything that shouldn't leak from one inode to the next. */
  545. memset(&vnode->fid, 0, sizeof(vnode->fid));
  546. memset(&vnode->status, 0, sizeof(vnode->status));
  547. vnode->volume = NULL;
  548. vnode->lock_key = NULL;
  549. vnode->permit_cache = NULL;
  550. vnode->cb_interest = NULL;
  551. #ifdef CONFIG_AFS_FSCACHE
  552. vnode->cache = NULL;
  553. #endif
  554. vnode->flags = 1 << AFS_VNODE_UNSET;
  555. vnode->cb_type = 0;
  556. vnode->lock_state = AFS_VNODE_LOCK_NONE;
  557. _leave(" = %p", &vnode->vfs_inode);
  558. return &vnode->vfs_inode;
  559. }
  560. static void afs_i_callback(struct rcu_head *head)
  561. {
  562. struct inode *inode = container_of(head, struct inode, i_rcu);
  563. struct afs_vnode *vnode = AFS_FS_I(inode);
  564. kmem_cache_free(afs_inode_cachep, vnode);
  565. }
  566. /*
  567. * destroy an AFS inode struct
  568. */
  569. static void afs_destroy_inode(struct inode *inode)
  570. {
  571. struct afs_vnode *vnode = AFS_FS_I(inode);
  572. _enter("%p{%x:%u}", inode, vnode->fid.vid, vnode->fid.vnode);
  573. _debug("DESTROY INODE %p", inode);
  574. ASSERTCMP(vnode->cb_interest, ==, NULL);
  575. call_rcu(&inode->i_rcu, afs_i_callback);
  576. atomic_dec(&afs_count_active_inodes);
  577. }
  578. /*
  579. * return information about an AFS volume
  580. */
  581. static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
  582. {
  583. struct afs_super_info *as = AFS_FS_S(dentry->d_sb);
  584. struct afs_fs_cursor fc;
  585. struct afs_volume_status vs;
  586. struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
  587. struct key *key;
  588. int ret;
  589. buf->f_type = dentry->d_sb->s_magic;
  590. buf->f_bsize = AFS_BLOCK_SIZE;
  591. buf->f_namelen = AFSNAMEMAX - 1;
  592. if (as->dyn_root) {
  593. buf->f_blocks = 1;
  594. buf->f_bavail = 0;
  595. buf->f_bfree = 0;
  596. return 0;
  597. }
  598. key = afs_request_key(vnode->volume->cell);
  599. if (IS_ERR(key))
  600. return PTR_ERR(key);
  601. ret = -ERESTARTSYS;
  602. if (afs_begin_vnode_operation(&fc, vnode, key)) {
  603. fc.flags |= AFS_FS_CURSOR_NO_VSLEEP;
  604. while (afs_select_fileserver(&fc)) {
  605. fc.cb_break = afs_calc_vnode_cb_break(vnode);
  606. afs_fs_get_volume_status(&fc, &vs);
  607. }
  608. afs_check_for_remote_deletion(&fc, fc.vnode);
  609. afs_vnode_commit_status(&fc, vnode, fc.cb_break);
  610. ret = afs_end_vnode_operation(&fc);
  611. }
  612. key_put(key);
  613. if (ret == 0) {
  614. if (vs.max_quota == 0)
  615. buf->f_blocks = vs.part_max_blocks;
  616. else
  617. buf->f_blocks = vs.max_quota;
  618. buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use;
  619. }
  620. return ret;
  621. }