hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/fs/cachefiles/rdwr.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Storage object read/write
23 *
34 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
45 * 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.
106 */
117
128 #include <linux/mount.h>
....@@ -28,17 +24,16 @@
2824 container_of(wait, struct cachefiles_one_read, monitor);
2925 struct cachefiles_object *object;
3026 struct fscache_retrieval *op = monitor->op;
31
- struct wait_bit_key *key = _key;
27
+ struct wait_page_key *key = _key;
3228 struct page *page = wait->private;
3329
3430 ASSERT(key);
3531
3632 _enter("{%lu},%u,%d,{%p,%u}",
3733 monitor->netfs_page->index, mode, sync,
38
- key->flags, key->bit_nr);
34
+ key->page, key->bit_nr);
3935
40
- if (key->flags != &page->flags ||
41
- key->bit_nr != PG_locked)
36
+ if (key->page != page || key->bit_nr != PG_locked)
4237 return 0;
4338
4439 _debug("--- monitor %p %lx ---", page, page->flags);
....@@ -401,9 +396,9 @@
401396 struct cachefiles_object *object;
402397 struct cachefiles_cache *cache;
403398 struct inode *inode;
404
- sector_t block0, block;
399
+ sector_t block;
405400 unsigned shift;
406
- int ret;
401
+ int ret, ret2;
407402
408403 object = container_of(op->op.object,
409404 struct cachefiles_object, fscache);
....@@ -417,8 +412,6 @@
417412
418413 inode = d_backing_inode(object->backer);
419414 ASSERT(S_ISREG(inode->i_mode));
420
- ASSERT(inode->i_mapping->a_ops->bmap);
421
- ASSERT(inode->i_mapping->a_ops->readpages);
422415
423416 /* calculate the shift required to use bmap */
424417 shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
....@@ -433,12 +426,14 @@
433426 * enough for this as it doesn't indicate errors, but it's all we've
434427 * got for the moment
435428 */
436
- block0 = page->index;
437
- block0 <<= shift;
429
+ block = page->index;
430
+ block <<= shift;
438431
439
- block = inode->i_mapping->a_ops->bmap(inode->i_mapping, block0);
432
+ ret2 = bmap(inode, &block);
433
+ ASSERT(ret2 == 0);
434
+
440435 _debug("%llx -> %llx",
441
- (unsigned long long) block0,
436
+ (unsigned long long) (page->index << shift),
442437 (unsigned long long) block);
443438
444439 if (block) {
....@@ -716,8 +711,6 @@
716711
717712 inode = d_backing_inode(object->backer);
718713 ASSERT(S_ISREG(inode->i_mode));
719
- ASSERT(inode->i_mapping->a_ops->bmap);
720
- ASSERT(inode->i_mapping->a_ops->readpages);
721714
722715 /* calculate the shift required to use bmap */
723716 shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
....@@ -733,7 +726,7 @@
733726
734727 ret = space ? -ENODATA : -ENOBUFS;
735728 list_for_each_entry_safe(page, _n, pages, lru) {
736
- sector_t block0, block;
729
+ sector_t block;
737730
738731 /* we assume the absence or presence of the first block is a
739732 * good enough indication for the page as a whole
....@@ -741,13 +734,14 @@
741734 * good enough for this as it doesn't indicate errors, but
742735 * it's all we've got for the moment
743736 */
744
- block0 = page->index;
745
- block0 <<= shift;
737
+ block = page->index;
738
+ block <<= shift;
746739
747
- block = inode->i_mapping->a_ops->bmap(inode->i_mapping,
748
- block0);
740
+ ret2 = bmap(inode, &block);
741
+ ASSERT(ret2 == 0);
742
+
749743 _debug("%llx -> %llx",
750
- (unsigned long long) block0,
744
+ (unsigned long long) (page->index << shift),
751745 (unsigned long long) block);
752746
753747 if (block) {
....@@ -941,7 +935,7 @@
941935 }
942936
943937 data = kmap(page);
944
- ret = __kernel_write(file, data, len, &pos);
938
+ ret = kernel_write(file, data, len, &pos);
945939 kunmap(page);
946940 fput(file);
947941 if (ret != len)