super.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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->dyn_root);
  311. }
  312. static int afs_dynroot_test_super(struct super_block *sb, void *data)
  313. {
  314. struct afs_super_info *as1 = data;
  315. struct afs_super_info *as = AFS_FS_S(sb);
  316. return (as->net_ns == as1->net_ns &&
  317. as->dyn_root);
  318. }
  319. static int afs_set_super(struct super_block *sb, void *data)
  320. {
  321. struct afs_super_info *as = data;
  322. sb->s_fs_info = as;
  323. return set_anon_super(sb, NULL);
  324. }
  325. /*
  326. * fill in the superblock
  327. */
  328. static int afs_fill_super(struct super_block *sb,
  329. struct afs_mount_params *params)
  330. {
  331. struct afs_super_info *as = AFS_FS_S(sb);
  332. struct afs_fid fid;
  333. struct inode *inode = NULL;
  334. int ret;
  335. _enter("");
  336. /* fill in the superblock */
  337. sb->s_blocksize = PAGE_SIZE;
  338. sb->s_blocksize_bits = PAGE_SHIFT;
  339. sb->s_magic = AFS_FS_MAGIC;
  340. sb->s_op = &afs_super_ops;
  341. if (!as->dyn_root)
  342. sb->s_xattr = afs_xattr_handlers;
  343. ret = super_setup_bdi(sb);
  344. if (ret)
  345. return ret;
  346. sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
  347. /* allocate the root inode and dentry */
  348. if (as->dyn_root) {
  349. inode = afs_iget_pseudo_dir(sb, true);
  350. sb->s_flags |= SB_RDONLY;
  351. } else {
  352. sprintf(sb->s_id, "%u", as->volume->vid);
  353. afs_activate_volume(as->volume);
  354. fid.vid = as->volume->vid;
  355. fid.vnode = 1;
  356. fid.unique = 1;
  357. inode = afs_iget(sb, params->key, &fid, NULL, NULL, NULL);
  358. }
  359. if (IS_ERR(inode))
  360. return PTR_ERR(inode);
  361. if (params->autocell || params->dyn_root)
  362. set_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags);
  363. ret = -ENOMEM;
  364. sb->s_root = d_make_root(inode);
  365. if (!sb->s_root)
  366. goto error;
  367. if (as->dyn_root) {
  368. sb->s_d_op = &afs_dynroot_dentry_operations;
  369. ret = afs_dynroot_populate(sb);
  370. if (ret < 0)
  371. goto error;
  372. } else {
  373. sb->s_d_op = &afs_fs_dentry_operations;
  374. }
  375. _leave(" = 0");
  376. return 0;
  377. error:
  378. _leave(" = %d", ret);
  379. return ret;
  380. }
  381. static struct afs_super_info *afs_alloc_sbi(struct afs_mount_params *params)
  382. {
  383. struct afs_super_info *as;
  384. as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
  385. if (as) {
  386. as->net_ns = get_net(params->net_ns);
  387. if (params->dyn_root)
  388. as->dyn_root = true;
  389. else
  390. as->cell = afs_get_cell(params->cell);
  391. }
  392. return as;
  393. }
  394. static void afs_destroy_sbi(struct afs_super_info *as)
  395. {
  396. if (as) {
  397. afs_put_volume(as->cell, as->volume);
  398. afs_put_cell(afs_net(as->net_ns), as->cell);
  399. put_net(as->net_ns);
  400. kfree(as);
  401. }
  402. }
  403. static void afs_kill_super(struct super_block *sb)
  404. {
  405. struct afs_super_info *as = AFS_FS_S(sb);
  406. struct afs_net *net = afs_net(as->net_ns);
  407. if (as->dyn_root)
  408. afs_dynroot_depopulate(sb);
  409. /* Clear the callback interests (which will do ilookup5) before
  410. * deactivating the superblock.
  411. */
  412. if (as->volume)
  413. afs_clear_callback_interests(net, as->volume->servers);
  414. kill_anon_super(sb);
  415. if (as->volume)
  416. afs_deactivate_volume(as->volume);
  417. afs_destroy_sbi(as);
  418. }
  419. /*
  420. * get an AFS superblock
  421. */
  422. static struct dentry *afs_mount(struct file_system_type *fs_type,
  423. int flags, const char *dev_name, void *options)
  424. {
  425. struct afs_mount_params params;
  426. struct super_block *sb;
  427. struct afs_volume *candidate;
  428. struct key *key;
  429. struct afs_super_info *as;
  430. int ret;
  431. _enter(",,%s,%p", dev_name, options);
  432. memset(&params, 0, sizeof(params));
  433. ret = -EINVAL;
  434. if (current->nsproxy->net_ns != &init_net)
  435. goto error;
  436. params.net_ns = current->nsproxy->net_ns;
  437. params.net = afs_net(params.net_ns);
  438. /* parse the options and device name */
  439. if (options) {
  440. ret = afs_parse_options(&params, options, &dev_name);
  441. if (ret < 0)
  442. goto error;
  443. }
  444. if (!params.dyn_root) {
  445. ret = afs_parse_device_name(&params, dev_name);
  446. if (ret < 0)
  447. goto error;
  448. /* try and do the mount securely */
  449. key = afs_request_key(params.cell);
  450. if (IS_ERR(key)) {
  451. _leave(" = %ld [key]", PTR_ERR(key));
  452. ret = PTR_ERR(key);
  453. goto error;
  454. }
  455. params.key = key;
  456. }
  457. /* allocate a superblock info record */
  458. ret = -ENOMEM;
  459. as = afs_alloc_sbi(&params);
  460. if (!as)
  461. goto error_key;
  462. if (!params.dyn_root) {
  463. /* Assume we're going to need a volume record; at the very
  464. * least we can use it to update the volume record if we have
  465. * one already. This checks that the volume exists within the
  466. * cell.
  467. */
  468. candidate = afs_create_volume(&params);
  469. if (IS_ERR(candidate)) {
  470. ret = PTR_ERR(candidate);
  471. goto error_as;
  472. }
  473. as->volume = candidate;
  474. }
  475. /* allocate a deviceless superblock */
  476. sb = sget(fs_type,
  477. as->dyn_root ? afs_dynroot_test_super : afs_test_super,
  478. afs_set_super, flags, as);
  479. if (IS_ERR(sb)) {
  480. ret = PTR_ERR(sb);
  481. goto error_as;
  482. }
  483. if (!sb->s_root) {
  484. /* initial superblock/root creation */
  485. _debug("create");
  486. ret = afs_fill_super(sb, &params);
  487. if (ret < 0)
  488. goto error_sb;
  489. as = NULL;
  490. sb->s_flags |= SB_ACTIVE;
  491. } else {
  492. _debug("reuse");
  493. ASSERTCMP(sb->s_flags, &, SB_ACTIVE);
  494. afs_destroy_sbi(as);
  495. as = NULL;
  496. }
  497. afs_put_cell(params.net, params.cell);
  498. key_put(params.key);
  499. _leave(" = 0 [%p]", sb);
  500. return dget(sb->s_root);
  501. error_sb:
  502. deactivate_locked_super(sb);
  503. goto error_key;
  504. error_as:
  505. afs_destroy_sbi(as);
  506. error_key:
  507. key_put(params.key);
  508. error:
  509. afs_put_cell(params.net, params.cell);
  510. _leave(" = %d", ret);
  511. return ERR_PTR(ret);
  512. }
  513. /*
  514. * Initialise an inode cache slab element prior to any use. Note that
  515. * afs_alloc_inode() *must* reset anything that could incorrectly leak from one
  516. * inode to another.
  517. */
  518. static void afs_i_init_once(void *_vnode)
  519. {
  520. struct afs_vnode *vnode = _vnode;
  521. memset(vnode, 0, sizeof(*vnode));
  522. inode_init_once(&vnode->vfs_inode);
  523. mutex_init(&vnode->io_lock);
  524. init_rwsem(&vnode->validate_lock);
  525. spin_lock_init(&vnode->wb_lock);
  526. spin_lock_init(&vnode->lock);
  527. INIT_LIST_HEAD(&vnode->wb_keys);
  528. INIT_LIST_HEAD(&vnode->pending_locks);
  529. INIT_LIST_HEAD(&vnode->granted_locks);
  530. INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
  531. seqlock_init(&vnode->cb_lock);
  532. }
  533. /*
  534. * allocate an AFS inode struct from our slab cache
  535. */
  536. static struct inode *afs_alloc_inode(struct super_block *sb)
  537. {
  538. struct afs_vnode *vnode;
  539. vnode = kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
  540. if (!vnode)
  541. return NULL;
  542. atomic_inc(&afs_count_active_inodes);
  543. /* Reset anything that shouldn't leak from one inode to the next. */
  544. memset(&vnode->fid, 0, sizeof(vnode->fid));
  545. memset(&vnode->status, 0, sizeof(vnode->status));
  546. vnode->volume = NULL;
  547. vnode->lock_key = NULL;
  548. vnode->permit_cache = NULL;
  549. vnode->cb_interest = NULL;
  550. #ifdef CONFIG_AFS_FSCACHE
  551. vnode->cache = NULL;
  552. #endif
  553. vnode->flags = 1 << AFS_VNODE_UNSET;
  554. vnode->cb_type = 0;
  555. vnode->lock_state = AFS_VNODE_LOCK_NONE;
  556. _leave(" = %p", &vnode->vfs_inode);
  557. return &vnode->vfs_inode;
  558. }
  559. static void afs_i_callback(struct rcu_head *head)
  560. {
  561. struct inode *inode = container_of(head, struct inode, i_rcu);
  562. struct afs_vnode *vnode = AFS_FS_I(inode);
  563. kmem_cache_free(afs_inode_cachep, vnode);
  564. }
  565. /*
  566. * destroy an AFS inode struct
  567. */
  568. static void afs_destroy_inode(struct inode *inode)
  569. {
  570. struct afs_vnode *vnode = AFS_FS_I(inode);
  571. _enter("%p{%x:%u}", inode, vnode->fid.vid, vnode->fid.vnode);
  572. _debug("DESTROY INODE %p", inode);
  573. ASSERTCMP(vnode->cb_interest, ==, NULL);
  574. call_rcu(&inode->i_rcu, afs_i_callback);
  575. atomic_dec(&afs_count_active_inodes);
  576. }
  577. /*
  578. * return information about an AFS volume
  579. */
  580. static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
  581. {
  582. struct afs_super_info *as = AFS_FS_S(dentry->d_sb);
  583. struct afs_fs_cursor fc;
  584. struct afs_volume_status vs;
  585. struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
  586. struct key *key;
  587. int ret;
  588. buf->f_type = dentry->d_sb->s_magic;
  589. buf->f_bsize = AFS_BLOCK_SIZE;
  590. buf->f_namelen = AFSNAMEMAX - 1;
  591. if (as->dyn_root) {
  592. buf->f_blocks = 1;
  593. buf->f_bavail = 0;
  594. buf->f_bfree = 0;
  595. return 0;
  596. }
  597. key = afs_request_key(vnode->volume->cell);
  598. if (IS_ERR(key))
  599. return PTR_ERR(key);
  600. ret = -ERESTARTSYS;
  601. if (afs_begin_vnode_operation(&fc, vnode, key)) {
  602. fc.flags |= AFS_FS_CURSOR_NO_VSLEEP;
  603. while (afs_select_fileserver(&fc)) {
  604. fc.cb_break = afs_calc_vnode_cb_break(vnode);
  605. afs_fs_get_volume_status(&fc, &vs);
  606. }
  607. afs_check_for_remote_deletion(&fc, fc.vnode);
  608. afs_vnode_commit_status(&fc, vnode, fc.cb_break);
  609. ret = afs_end_vnode_operation(&fc);
  610. }
  611. key_put(key);
  612. if (ret == 0) {
  613. if (vs.max_quota == 0)
  614. buf->f_blocks = vs.part_max_blocks;
  615. else
  616. buf->f_blocks = vs.max_quota;
  617. buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use;
  618. }
  619. return ret;
  620. }