[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <158861233866.340223.12898035701656989480.stgit@warthog.procyon.org.uk>
Date: Mon, 04 May 2020 18:12:18 +0100
From: David Howells <dhowells@...hat.com>
To: Trond Myklebust <trondmy@...merspace.com>,
Anna Schumaker <anna.schumaker@...app.com>,
Steve French <sfrench@...ba.org>,
Jeff Layton <jlayton@...hat.com>
Cc: dhowells@...hat.com, Matthew Wilcox <willy@...radead.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-afs@...ts.infradead.org, linux-nfs@...r.kernel.org,
linux-cifs@...r.kernel.org, ceph-devel@...r.kernel.org,
v9fs-developer@...ts.sourceforge.net,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC PATCH 32/61] cachefiles: Merge object->backer into
object->dentry
Merge the object->backer pointer into the object->dentry pointer and assume
that data objects are always going to be just regular files.
object->dentry can then more easily be overridden later by invalidation
without having two different things to update the xattrs on.
object->old maintains a pointer to the old file so that we can unlink the
it later.
Signed-off-by: David Howells <dhowells@...hat.com>
---
fs/cachefiles/interface.c | 35 +++++++++++++++++------------------
fs/cachefiles/internal.h | 2 +-
fs/cachefiles/io.c | 4 ++--
fs/cachefiles/namei.c | 4 +++-
4 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c
index 747211363ae0..bb68318fcc1c 100644
--- a/fs/cachefiles/interface.c
+++ b/fs/cachefiles/interface.c
@@ -171,16 +171,16 @@ static void cachefiles_update_object(struct fscache_object *_object)
cachefiles_begin_secure(cache, &saved_cred);
object_size = object->fscache.cookie->object_size;
- if (i_size_read(d_inode(object->backer)) > object_size) {
+ if (i_size_read(d_inode(object->dentry)) > object_size) {
struct path path = {
.mnt = cache->mnt,
- .dentry = object->backer
+ .dentry = object->dentry
};
- _debug("trunc %llx -> %llx", i_size_read(d_inode(object->backer)), object_size);
+ _debug("trunc %llx -> %llx", i_size_read(d_inode(object->dentry)), object_size);
ret = vfs_truncate(&path, object_size);
if (ret < 0) {
cachefiles_io_error_obj(object, "Trunc-to-size failed");
- cachefiles_remove_object_xattr(cache, object->backer);
+ cachefiles_remove_object_xattr(cache, object->dentry);
goto out;
}
}
@@ -219,9 +219,8 @@ static void cachefiles_clean_up_object(struct cachefiles_object *object,
fput(object->backing_file);
object->backing_file = NULL;
- if (object->backer != object->dentry)
- dput(object->backer);
- object->backer = NULL;
+ dput(object->old);
+ object->old = NULL;
cachefiles_unmark_inode_in_use(object, object->dentry);
dput(object->dentry);
@@ -299,7 +298,7 @@ static void cachefiles_put_object(struct fscache_object *_object,
_debug("- kill object OBJ%x", object->fscache.debug_id);
ASSERTCMP(object->fscache.parent, ==, NULL);
- ASSERTCMP(object->backer, ==, NULL);
+ ASSERTCMP(object->old, ==, NULL);
ASSERTCMP(object->dentry, ==, NULL);
ASSERTCMP(object->fscache.n_children, ==, 0);
@@ -364,17 +363,17 @@ static int cachefiles_attr_changed(struct cachefiles_object *object)
if (ni_size == object->i_size)
return 0;
- if (!object->backer)
+ if (!object->dentry)
return -ENOBUFS;
- ASSERT(d_is_reg(object->backer));
+ ASSERT(d_is_reg(object->dentry));
- oi_size = i_size_read(d_backing_inode(object->backer));
+ oi_size = i_size_read(d_backing_inode(object->dentry));
if (oi_size == ni_size)
return 0;
cachefiles_begin_secure(cache, &saved_cred);
- inode_lock(d_inode(object->backer));
+ inode_lock(d_inode(object->dentry));
/* if there's an extension to a partial page at the end of the backing
* file, we need to discard the partial page so that we pick up new
@@ -383,17 +382,17 @@ static int cachefiles_attr_changed(struct cachefiles_object *object)
_debug("discard tail %llx", oi_size);
newattrs.ia_valid = ATTR_SIZE;
newattrs.ia_size = oi_size & PAGE_MASK;
- ret = notify_change(object->backer, &newattrs, NULL);
+ ret = notify_change(object->dentry, &newattrs, NULL);
if (ret < 0)
goto truncate_failed;
}
newattrs.ia_valid = ATTR_SIZE;
newattrs.ia_size = ni_size;
- ret = notify_change(object->backer, &newattrs, NULL);
+ ret = notify_change(object->dentry, &newattrs, NULL);
truncate_failed:
- inode_unlock(d_inode(object->backer));
+ inode_unlock(d_inode(object->dentry));
cachefiles_end_secure(cache, saved_cred);
if (ret == -EIO) {
@@ -426,10 +425,10 @@ static void cachefiles_invalidate_object(struct fscache_object *_object)
_enter("{OBJ%x},[%llu]",
object->fscache.debug_id, (unsigned long long)ni_size);
- if (object->backer) {
- ASSERT(d_is_reg(object->backer));
+ if (object->dentry) {
+ ASSERT(d_is_reg(object->dentry));
- path.dentry = object->backer;
+ path.dentry = object->dentry;
path.mnt = cache->mnt;
cachefiles_begin_secure(cache, &saved_cred);
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
index 9f9e33893b4f..e605cffc284d 100644
--- a/fs/cachefiles/internal.h
+++ b/fs/cachefiles/internal.h
@@ -35,7 +35,7 @@ extern unsigned cachefiles_debug;
struct cachefiles_object {
struct fscache_object fscache; /* fscache handle */
struct dentry *dentry; /* the file/dir representing this object */
- struct dentry *backer; /* backing file */
+ struct dentry *old; /* backing file */
struct file *backing_file; /* File open on backing storage */
loff_t i_size; /* object size */
atomic_t usage; /* object usage count */
diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index d472e9d9173c..2384067e716d 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -60,11 +60,11 @@ bool cachefiles_open_object(struct cachefiles_object *object)
struct path path;
path.mnt = cache->mnt;
- path.dentry = object->backer;
+ path.dentry = object->dentry;
file = open_with_fake_path(&path,
O_RDWR | O_LARGEFILE | O_DIRECT,
- d_backing_inode(object->backer),
+ d_backing_inode(object->dentry),
cache->cache_cred);
if (IS_ERR(file))
goto error;
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index c33b5ee65ac1..d697a74436c0 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -488,7 +488,7 @@ bool cachefiles_walk_to_object(struct cachefiles_object *parent,
goto check_error;
}
- object->backer = object->dentry;
+ object->old = dget(object->dentry);
} else {
BUG(); // TODO: open file in data-class subdir
}
@@ -523,7 +523,9 @@ bool cachefiles_walk_to_object(struct cachefiles_object *parent,
cachefiles_unmark_inode_in_use(object, object->dentry);
cachefiles_mark_object_inactive(cache, object);
dput(object->dentry);
+ dput(object->old);
object->dentry = NULL;
+ object->old = NULL;
goto error_out;
lookup_error:
Powered by blists - more mailing lists