Lines Matching defs:cache
250 static void hmdfs_set_stash_file_head(const struct hmdfs_cache_info *cache,
260 head->size = cpu_to_le64(i_size_read(file_inode(cache->cache_file)));
261 blocks = atomic64_read(&cache->written_pgs) <<
264 head->path_offs = cpu_to_le32(cache->path_offs);
265 head->path_len = cpu_to_le32(cache->path_len);
266 head->path_cnt = cpu_to_le32(cache->path_cnt);
267 head->data_offs = cpu_to_le32(cache->data_offs);
275 struct hmdfs_cache_info *cache = NULL;
282 /* No metadata if no cache file info */
283 cache = info->cache;
284 if (!cache)
287 if (strlen(cache->path) == 0) {
288 long long to_write_pgs = atomic64_read(&cache->to_write_pgs);
300 hmdfs_set_stash_file_head(cache, info->remote_ino, &cache_head);
305 written = kernel_write(cache->cache_file, &cache_head, head_size, &pos);
313 pos = (loff_t)cache->path_offs << HMDFS_STASH_BLK_SHIFT;
314 written = kernel_write(cache->cache_file, cache->path, cache->path_len,
316 if (written != cache->path_len) {
319 cache->path_len, written);
371 /* b93b016313b3b ("page cache: use xa_lock") introduces i_pages */
516 struct file *cache_file = info->cache->cache_file;
519 long long to_write_pgs = atomic64_read(&info->cache->to_write_pgs);
538 static void hmdfs_del_file_cache(struct hmdfs_cache_info *cache)
540 if (!cache)
543 fput(cache->cache_file);
544 kfree(cache->path_buf);
545 kfree(cache);
551 struct hmdfs_cache_info *cache = NULL;
555 cache = kzalloc(sizeof(*cache), GFP_KERNEL);
556 if (!cache)
559 atomic64_set(&cache->to_write_pgs, 0);
560 atomic64_set(&cache->written_pgs, 0);
561 cache->path_buf = kmalloc(PATH_MAX, GFP_KERNEL);
562 if (!cache->path_buf) {
571 cache->path = dentry_path_raw(stash_dentry, cache->path_buf,
574 if (IS_ERR(cache->path)) {
575 err = PTR_ERR(cache->path);
585 cache->path_buf[0] = '\0';
586 cache->path = cache->path_buf;
589 cache->path_cnt = 1;
590 cache->path_len = strlen(cache->path) + 1;
591 cache->path_offs = DIV_ROUND_UP(sizeof(struct hmdfs_cache_file_head),
593 cache->data_offs = cache->path_offs + DIV_ROUND_UP(cache->path_len,
595 cache->cache_file = hmdfs_new_stash_file(&conn->sbi->stash_work_dir,
597 if (IS_ERR(cache->cache_file)) {
598 err = PTR_ERR(cache->cache_file);
602 return cache;
605 kfree(cache->path_buf);
607 kfree(cache);
614 struct hmdfs_cache_info *cache = NULL;
616 cache = hmdfs_new_file_cache(conn, info);
617 if (IS_ERR(cache))
623 cache = NULL;
627 info->cache = cache;
633 const struct hmdfs_cache_info *cache,
638 if (cache) {
639 ok_pages = err > 0 ? atomic64_read(&cache->written_pgs) : 0;
640 fail_pages = atomic64_read(&cache->to_write_pgs) - ok_pages;
657 struct hmdfs_cache_info *cache = info->cache;
674 info->cache = NULL;
682 hmdfs_update_stash_stats(stats, cache, err);
683 hmdfs_del_file_cache(cache);
1454 /* Remove the unnecessary cache */
1983 struct hmdfs_cache_info *cache = NULL;
1986 cache = info->cache;
1987 info->cache = NULL;
1992 hmdfs_del_file_cache(cache);
2032 hmdfs_err("invalid cache dir err %d", err);
2053 struct hmdfs_cache_info *cache)
2068 pos += cache->data_offs << HMDFS_STASH_BLK_SHIFT;
2069 written = kernel_write(cache->cache_file, buf, ctx->count, &pos);
2077 page->index, cache->data_offs, ctx->count, written);
2089 struct hmdfs_cache_info *cache = NULL;
2093 cache = info->cache;
2094 if (!cache)
2097 err = hmdfs_stash_write_local_file(conn, info, ctx, cache);
2100 atomic64_inc(&cache->written_pgs);
2104 atomic64_inc(&cache->to_write_pgs);