daemon.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. /* Daemon interface
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/sched.h>
  14. #include <linux/completion.h>
  15. #include <linux/slab.h>
  16. #include <linux/fs.h>
  17. #include <linux/file.h>
  18. #include <linux/namei.h>
  19. #include <linux/poll.h>
  20. #include <linux/mount.h>
  21. #include <linux/statfs.h>
  22. #include <linux/ctype.h>
  23. #include <linux/string.h>
  24. #include <linux/fs_struct.h>
  25. #include "internal.h"
  26. static int cachefiles_daemon_open(struct inode *, struct file *);
  27. static int cachefiles_daemon_release(struct inode *, struct file *);
  28. static ssize_t cachefiles_daemon_read(struct file *, char __user *, size_t,
  29. loff_t *);
  30. static ssize_t cachefiles_daemon_write(struct file *, const char __user *,
  31. size_t, loff_t *);
  32. static unsigned int cachefiles_daemon_poll(struct file *,
  33. struct poll_table_struct *);
  34. static int cachefiles_daemon_frun(struct cachefiles_cache *, char *);
  35. static int cachefiles_daemon_fcull(struct cachefiles_cache *, char *);
  36. static int cachefiles_daemon_fstop(struct cachefiles_cache *, char *);
  37. static int cachefiles_daemon_brun(struct cachefiles_cache *, char *);
  38. static int cachefiles_daemon_bcull(struct cachefiles_cache *, char *);
  39. static int cachefiles_daemon_bstop(struct cachefiles_cache *, char *);
  40. static int cachefiles_daemon_cull(struct cachefiles_cache *, char *);
  41. static int cachefiles_daemon_debug(struct cachefiles_cache *, char *);
  42. static int cachefiles_daemon_dir(struct cachefiles_cache *, char *);
  43. static int cachefiles_daemon_inuse(struct cachefiles_cache *, char *);
  44. static int cachefiles_daemon_secctx(struct cachefiles_cache *, char *);
  45. static int cachefiles_daemon_tag(struct cachefiles_cache *, char *);
  46. static unsigned long cachefiles_open;
  47. const struct file_operations cachefiles_daemon_fops = {
  48. .owner = THIS_MODULE,
  49. .open = cachefiles_daemon_open,
  50. .release = cachefiles_daemon_release,
  51. .read = cachefiles_daemon_read,
  52. .write = cachefiles_daemon_write,
  53. .poll = cachefiles_daemon_poll,
  54. .llseek = noop_llseek,
  55. };
  56. struct cachefiles_daemon_cmd {
  57. char name[8];
  58. int (*handler)(struct cachefiles_cache *cache, char *args);
  59. };
  60. static const struct cachefiles_daemon_cmd cachefiles_daemon_cmds[] = {
  61. { "bind", cachefiles_daemon_bind },
  62. { "brun", cachefiles_daemon_brun },
  63. { "bcull", cachefiles_daemon_bcull },
  64. { "bstop", cachefiles_daemon_bstop },
  65. { "cull", cachefiles_daemon_cull },
  66. { "debug", cachefiles_daemon_debug },
  67. { "dir", cachefiles_daemon_dir },
  68. { "frun", cachefiles_daemon_frun },
  69. { "fcull", cachefiles_daemon_fcull },
  70. { "fstop", cachefiles_daemon_fstop },
  71. { "inuse", cachefiles_daemon_inuse },
  72. { "secctx", cachefiles_daemon_secctx },
  73. { "tag", cachefiles_daemon_tag },
  74. { "", NULL }
  75. };
  76. /*
  77. * do various checks
  78. */
  79. static int cachefiles_daemon_open(struct inode *inode, struct file *file)
  80. {
  81. struct cachefiles_cache *cache;
  82. _enter("");
  83. /* only the superuser may do this */
  84. if (!capable(CAP_SYS_ADMIN))
  85. return -EPERM;
  86. /* the cachefiles device may only be open once at a time */
  87. if (xchg(&cachefiles_open, 1) == 1)
  88. return -EBUSY;
  89. /* allocate a cache record */
  90. cache = kzalloc(sizeof(struct cachefiles_cache), GFP_KERNEL);
  91. if (!cache) {
  92. cachefiles_open = 0;
  93. return -ENOMEM;
  94. }
  95. mutex_init(&cache->daemon_mutex);
  96. cache->active_nodes = RB_ROOT;
  97. rwlock_init(&cache->active_lock);
  98. init_waitqueue_head(&cache->daemon_pollwq);
  99. /* set default caching limits
  100. * - limit at 1% free space and/or free files
  101. * - cull below 5% free space and/or free files
  102. * - cease culling above 7% free space and/or free files
  103. */
  104. cache->frun_percent = 7;
  105. cache->fcull_percent = 5;
  106. cache->fstop_percent = 1;
  107. cache->brun_percent = 7;
  108. cache->bcull_percent = 5;
  109. cache->bstop_percent = 1;
  110. file->private_data = cache;
  111. cache->cachefilesd = file;
  112. return 0;
  113. }
  114. /*
  115. * release a cache
  116. */
  117. static int cachefiles_daemon_release(struct inode *inode, struct file *file)
  118. {
  119. struct cachefiles_cache *cache = file->private_data;
  120. _enter("");
  121. ASSERT(cache);
  122. set_bit(CACHEFILES_DEAD, &cache->flags);
  123. cachefiles_daemon_unbind(cache);
  124. ASSERT(!cache->active_nodes.rb_node);
  125. /* clean up the control file interface */
  126. cache->cachefilesd = NULL;
  127. file->private_data = NULL;
  128. cachefiles_open = 0;
  129. kfree(cache);
  130. _leave("");
  131. return 0;
  132. }
  133. /*
  134. * read the cache state
  135. */
  136. static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
  137. size_t buflen, loff_t *pos)
  138. {
  139. struct cachefiles_cache *cache = file->private_data;
  140. unsigned long long b_released;
  141. unsigned f_released;
  142. char buffer[256];
  143. int n;
  144. //_enter(",,%zu,", buflen);
  145. if (!test_bit(CACHEFILES_READY, &cache->flags))
  146. return 0;
  147. /* check how much space the cache has */
  148. cachefiles_has_space(cache, 0, 0);
  149. /* summarise */
  150. f_released = atomic_xchg(&cache->f_released, 0);
  151. b_released = atomic_long_xchg(&cache->b_released, 0);
  152. clear_bit(CACHEFILES_STATE_CHANGED, &cache->flags);
  153. n = snprintf(buffer, sizeof(buffer),
  154. "cull=%c"
  155. " frun=%llx"
  156. " fcull=%llx"
  157. " fstop=%llx"
  158. " brun=%llx"
  159. " bcull=%llx"
  160. " bstop=%llx"
  161. " freleased=%x"
  162. " breleased=%llx",
  163. test_bit(CACHEFILES_CULLING, &cache->flags) ? '1' : '0',
  164. (unsigned long long) cache->frun,
  165. (unsigned long long) cache->fcull,
  166. (unsigned long long) cache->fstop,
  167. (unsigned long long) cache->brun,
  168. (unsigned long long) cache->bcull,
  169. (unsigned long long) cache->bstop,
  170. f_released,
  171. b_released);
  172. if (n > buflen)
  173. return -EMSGSIZE;
  174. if (copy_to_user(_buffer, buffer, n) != 0)
  175. return -EFAULT;
  176. return n;
  177. }
  178. /*
  179. * command the cache
  180. */
  181. static ssize_t cachefiles_daemon_write(struct file *file,
  182. const char __user *_data,
  183. size_t datalen,
  184. loff_t *pos)
  185. {
  186. const struct cachefiles_daemon_cmd *cmd;
  187. struct cachefiles_cache *cache = file->private_data;
  188. ssize_t ret;
  189. char *data, *args, *cp;
  190. //_enter(",,%zu,", datalen);
  191. ASSERT(cache);
  192. if (test_bit(CACHEFILES_DEAD, &cache->flags))
  193. return -EIO;
  194. if (datalen < 0 || datalen > PAGE_SIZE - 1)
  195. return -EOPNOTSUPP;
  196. /* drag the command string into the kernel so we can parse it */
  197. data = memdup_user_nul(_data, datalen);
  198. if (IS_ERR(data))
  199. return PTR_ERR(data);
  200. ret = -EINVAL;
  201. if (memchr(data, '\0', datalen))
  202. goto error;
  203. /* strip any newline */
  204. cp = memchr(data, '\n', datalen);
  205. if (cp) {
  206. if (cp == data)
  207. goto error;
  208. *cp = '\0';
  209. }
  210. /* parse the command */
  211. ret = -EOPNOTSUPP;
  212. for (args = data; *args; args++)
  213. if (isspace(*args))
  214. break;
  215. if (*args) {
  216. if (args == data)
  217. goto error;
  218. *args = '\0';
  219. args = skip_spaces(++args);
  220. }
  221. /* run the appropriate command handler */
  222. for (cmd = cachefiles_daemon_cmds; cmd->name[0]; cmd++)
  223. if (strcmp(cmd->name, data) == 0)
  224. goto found_command;
  225. error:
  226. kfree(data);
  227. //_leave(" = %zd", ret);
  228. return ret;
  229. found_command:
  230. mutex_lock(&cache->daemon_mutex);
  231. ret = -EIO;
  232. if (!test_bit(CACHEFILES_DEAD, &cache->flags))
  233. ret = cmd->handler(cache, args);
  234. mutex_unlock(&cache->daemon_mutex);
  235. if (ret == 0)
  236. ret = datalen;
  237. goto error;
  238. }
  239. /*
  240. * poll for culling state
  241. * - use POLLOUT to indicate culling state
  242. */
  243. static unsigned int cachefiles_daemon_poll(struct file *file,
  244. struct poll_table_struct *poll)
  245. {
  246. struct cachefiles_cache *cache = file->private_data;
  247. unsigned int mask;
  248. poll_wait(file, &cache->daemon_pollwq, poll);
  249. mask = 0;
  250. if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags))
  251. mask |= POLLIN;
  252. if (test_bit(CACHEFILES_CULLING, &cache->flags))
  253. mask |= POLLOUT;
  254. return mask;
  255. }
  256. /*
  257. * give a range error for cache space constraints
  258. * - can be tail-called
  259. */
  260. static int cachefiles_daemon_range_error(struct cachefiles_cache *cache,
  261. char *args)
  262. {
  263. pr_err("Free space limits must be in range 0%%<=stop<cull<run<100%%\n");
  264. return -EINVAL;
  265. }
  266. /*
  267. * set the percentage of files at which to stop culling
  268. * - command: "frun <N>%"
  269. */
  270. static int cachefiles_daemon_frun(struct cachefiles_cache *cache, char *args)
  271. {
  272. unsigned long frun;
  273. _enter(",%s", args);
  274. if (!*args)
  275. return -EINVAL;
  276. frun = simple_strtoul(args, &args, 10);
  277. if (args[0] != '%' || args[1] != '\0')
  278. return -EINVAL;
  279. if (frun <= cache->fcull_percent || frun >= 100)
  280. return cachefiles_daemon_range_error(cache, args);
  281. cache->frun_percent = frun;
  282. return 0;
  283. }
  284. /*
  285. * set the percentage of files at which to start culling
  286. * - command: "fcull <N>%"
  287. */
  288. static int cachefiles_daemon_fcull(struct cachefiles_cache *cache, char *args)
  289. {
  290. unsigned long fcull;
  291. _enter(",%s", args);
  292. if (!*args)
  293. return -EINVAL;
  294. fcull = simple_strtoul(args, &args, 10);
  295. if (args[0] != '%' || args[1] != '\0')
  296. return -EINVAL;
  297. if (fcull <= cache->fstop_percent || fcull >= cache->frun_percent)
  298. return cachefiles_daemon_range_error(cache, args);
  299. cache->fcull_percent = fcull;
  300. return 0;
  301. }
  302. /*
  303. * set the percentage of files at which to stop allocating
  304. * - command: "fstop <N>%"
  305. */
  306. static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
  307. {
  308. unsigned long fstop;
  309. _enter(",%s", args);
  310. if (!*args)
  311. return -EINVAL;
  312. fstop = simple_strtoul(args, &args, 10);
  313. if (args[0] != '%' || args[1] != '\0')
  314. return -EINVAL;
  315. if (fstop < 0 || fstop >= cache->fcull_percent)
  316. return cachefiles_daemon_range_error(cache, args);
  317. cache->fstop_percent = fstop;
  318. return 0;
  319. }
  320. /*
  321. * set the percentage of blocks at which to stop culling
  322. * - command: "brun <N>%"
  323. */
  324. static int cachefiles_daemon_brun(struct cachefiles_cache *cache, char *args)
  325. {
  326. unsigned long brun;
  327. _enter(",%s", args);
  328. if (!*args)
  329. return -EINVAL;
  330. brun = simple_strtoul(args, &args, 10);
  331. if (args[0] != '%' || args[1] != '\0')
  332. return -EINVAL;
  333. if (brun <= cache->bcull_percent || brun >= 100)
  334. return cachefiles_daemon_range_error(cache, args);
  335. cache->brun_percent = brun;
  336. return 0;
  337. }
  338. /*
  339. * set the percentage of blocks at which to start culling
  340. * - command: "bcull <N>%"
  341. */
  342. static int cachefiles_daemon_bcull(struct cachefiles_cache *cache, char *args)
  343. {
  344. unsigned long bcull;
  345. _enter(",%s", args);
  346. if (!*args)
  347. return -EINVAL;
  348. bcull = simple_strtoul(args, &args, 10);
  349. if (args[0] != '%' || args[1] != '\0')
  350. return -EINVAL;
  351. if (bcull <= cache->bstop_percent || bcull >= cache->brun_percent)
  352. return cachefiles_daemon_range_error(cache, args);
  353. cache->bcull_percent = bcull;
  354. return 0;
  355. }
  356. /*
  357. * set the percentage of blocks at which to stop allocating
  358. * - command: "bstop <N>%"
  359. */
  360. static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
  361. {
  362. unsigned long bstop;
  363. _enter(",%s", args);
  364. if (!*args)
  365. return -EINVAL;
  366. bstop = simple_strtoul(args, &args, 10);
  367. if (args[0] != '%' || args[1] != '\0')
  368. return -EINVAL;
  369. if (bstop < 0 || bstop >= cache->bcull_percent)
  370. return cachefiles_daemon_range_error(cache, args);
  371. cache->bstop_percent = bstop;
  372. return 0;
  373. }
  374. /*
  375. * set the cache directory
  376. * - command: "dir <name>"
  377. */
  378. static int cachefiles_daemon_dir(struct cachefiles_cache *cache, char *args)
  379. {
  380. char *dir;
  381. _enter(",%s", args);
  382. if (!*args) {
  383. pr_err("Empty directory specified\n");
  384. return -EINVAL;
  385. }
  386. if (cache->rootdirname) {
  387. pr_err("Second cache directory specified\n");
  388. return -EEXIST;
  389. }
  390. dir = kstrdup(args, GFP_KERNEL);
  391. if (!dir)
  392. return -ENOMEM;
  393. cache->rootdirname = dir;
  394. return 0;
  395. }
  396. /*
  397. * set the cache security context
  398. * - command: "secctx <ctx>"
  399. */
  400. static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args)
  401. {
  402. char *secctx;
  403. _enter(",%s", args);
  404. if (!*args) {
  405. pr_err("Empty security context specified\n");
  406. return -EINVAL;
  407. }
  408. if (cache->secctx) {
  409. pr_err("Second security context specified\n");
  410. return -EINVAL;
  411. }
  412. secctx = kstrdup(args, GFP_KERNEL);
  413. if (!secctx)
  414. return -ENOMEM;
  415. cache->secctx = secctx;
  416. return 0;
  417. }
  418. /*
  419. * set the cache tag
  420. * - command: "tag <name>"
  421. */
  422. static int cachefiles_daemon_tag(struct cachefiles_cache *cache, char *args)
  423. {
  424. char *tag;
  425. _enter(",%s", args);
  426. if (!*args) {
  427. pr_err("Empty tag specified\n");
  428. return -EINVAL;
  429. }
  430. if (cache->tag)
  431. return -EEXIST;
  432. tag = kstrdup(args, GFP_KERNEL);
  433. if (!tag)
  434. return -ENOMEM;
  435. cache->tag = tag;
  436. return 0;
  437. }
  438. /*
  439. * request a node in the cache be culled from the current working directory
  440. * - command: "cull <name>"
  441. */
  442. static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
  443. {
  444. struct path path;
  445. const struct cred *saved_cred;
  446. int ret;
  447. _enter(",%s", args);
  448. if (strchr(args, '/'))
  449. goto inval;
  450. if (!test_bit(CACHEFILES_READY, &cache->flags)) {
  451. pr_err("cull applied to unready cache\n");
  452. return -EIO;
  453. }
  454. if (test_bit(CACHEFILES_DEAD, &cache->flags)) {
  455. pr_err("cull applied to dead cache\n");
  456. return -EIO;
  457. }
  458. /* extract the directory dentry from the cwd */
  459. get_fs_pwd(current->fs, &path);
  460. if (!d_can_lookup(path.dentry))
  461. goto notdir;
  462. cachefiles_begin_secure(cache, &saved_cred);
  463. ret = cachefiles_cull(cache, path.dentry, args);
  464. cachefiles_end_secure(cache, saved_cred);
  465. path_put(&path);
  466. _leave(" = %d", ret);
  467. return ret;
  468. notdir:
  469. path_put(&path);
  470. pr_err("cull command requires dirfd to be a directory\n");
  471. return -ENOTDIR;
  472. inval:
  473. pr_err("cull command requires dirfd and filename\n");
  474. return -EINVAL;
  475. }
  476. /*
  477. * set debugging mode
  478. * - command: "debug <mask>"
  479. */
  480. static int cachefiles_daemon_debug(struct cachefiles_cache *cache, char *args)
  481. {
  482. unsigned long mask;
  483. _enter(",%s", args);
  484. mask = simple_strtoul(args, &args, 0);
  485. if (args[0] != '\0')
  486. goto inval;
  487. cachefiles_debug = mask;
  488. _leave(" = 0");
  489. return 0;
  490. inval:
  491. pr_err("debug command requires mask\n");
  492. return -EINVAL;
  493. }
  494. /*
  495. * find out whether an object in the current working directory is in use or not
  496. * - command: "inuse <name>"
  497. */
  498. static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
  499. {
  500. struct path path;
  501. const struct cred *saved_cred;
  502. int ret;
  503. //_enter(",%s", args);
  504. if (strchr(args, '/'))
  505. goto inval;
  506. if (!test_bit(CACHEFILES_READY, &cache->flags)) {
  507. pr_err("inuse applied to unready cache\n");
  508. return -EIO;
  509. }
  510. if (test_bit(CACHEFILES_DEAD, &cache->flags)) {
  511. pr_err("inuse applied to dead cache\n");
  512. return -EIO;
  513. }
  514. /* extract the directory dentry from the cwd */
  515. get_fs_pwd(current->fs, &path);
  516. if (!d_can_lookup(path.dentry))
  517. goto notdir;
  518. cachefiles_begin_secure(cache, &saved_cred);
  519. ret = cachefiles_check_in_use(cache, path.dentry, args);
  520. cachefiles_end_secure(cache, saved_cred);
  521. path_put(&path);
  522. //_leave(" = %d", ret);
  523. return ret;
  524. notdir:
  525. path_put(&path);
  526. pr_err("inuse command requires dirfd to be a directory\n");
  527. return -ENOTDIR;
  528. inval:
  529. pr_err("inuse command requires dirfd and filename\n");
  530. return -EINVAL;
  531. }
  532. /*
  533. * see if we have space for a number of pages and/or a number of files in the
  534. * cache
  535. */
  536. int cachefiles_has_space(struct cachefiles_cache *cache,
  537. unsigned fnr, unsigned bnr)
  538. {
  539. struct kstatfs stats;
  540. struct path path = {
  541. .mnt = cache->mnt,
  542. .dentry = cache->mnt->mnt_root,
  543. };
  544. int ret;
  545. //_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u",
  546. // (unsigned long long) cache->frun,
  547. // (unsigned long long) cache->fcull,
  548. // (unsigned long long) cache->fstop,
  549. // (unsigned long long) cache->brun,
  550. // (unsigned long long) cache->bcull,
  551. // (unsigned long long) cache->bstop,
  552. // fnr, bnr);
  553. /* find out how many pages of blockdev are available */
  554. memset(&stats, 0, sizeof(stats));
  555. ret = vfs_statfs(&path, &stats);
  556. if (ret < 0) {
  557. if (ret == -EIO)
  558. cachefiles_io_error(cache, "statfs failed");
  559. _leave(" = %d", ret);
  560. return ret;
  561. }
  562. stats.f_bavail >>= cache->bshift;
  563. //_debug("avail %llu,%llu",
  564. // (unsigned long long) stats.f_ffree,
  565. // (unsigned long long) stats.f_bavail);
  566. /* see if there is sufficient space */
  567. if (stats.f_ffree > fnr)
  568. stats.f_ffree -= fnr;
  569. else
  570. stats.f_ffree = 0;
  571. if (stats.f_bavail > bnr)
  572. stats.f_bavail -= bnr;
  573. else
  574. stats.f_bavail = 0;
  575. ret = -ENOBUFS;
  576. if (stats.f_ffree < cache->fstop ||
  577. stats.f_bavail < cache->bstop)
  578. goto begin_cull;
  579. ret = 0;
  580. if (stats.f_ffree < cache->fcull ||
  581. stats.f_bavail < cache->bcull)
  582. goto begin_cull;
  583. if (test_bit(CACHEFILES_CULLING, &cache->flags) &&
  584. stats.f_ffree >= cache->frun &&
  585. stats.f_bavail >= cache->brun &&
  586. test_and_clear_bit(CACHEFILES_CULLING, &cache->flags)
  587. ) {
  588. _debug("cease culling");
  589. cachefiles_state_changed(cache);
  590. }
  591. //_leave(" = 0");
  592. return 0;
  593. begin_cull:
  594. if (!test_and_set_bit(CACHEFILES_CULLING, &cache->flags)) {
  595. _debug("### CULL CACHE ###");
  596. cachefiles_state_changed(cache);
  597. }
  598. _leave(" = %d", ret);
  599. return ret;
  600. }