fuse: reduce size of struct fuse_inode
Do this by grouping fields used for cached writes and putting them into a union with fileds used for cached readdir (with obviously no overlap, since we don't have hybrid objects). Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
parent
261aaba72f
commit
ab2257e994
|
@ -1414,8 +1414,11 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
|
||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr->ia_valid & ATTR_SIZE)
|
if (attr->ia_valid & ATTR_SIZE) {
|
||||||
|
if (WARN_ON(!S_ISREG(inode->i_mode)))
|
||||||
|
return -EIO;
|
||||||
is_truncate = true;
|
is_truncate = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_truncate) {
|
if (is_truncate) {
|
||||||
fuse_set_nowrite(inode);
|
fuse_set_nowrite(inode);
|
||||||
|
@ -1619,8 +1622,16 @@ void fuse_init_common(struct inode *inode)
|
||||||
|
|
||||||
void fuse_init_dir(struct inode *inode)
|
void fuse_init_dir(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct fuse_inode *fi = get_fuse_inode(inode);
|
||||||
|
|
||||||
inode->i_op = &fuse_dir_inode_operations;
|
inode->i_op = &fuse_dir_inode_operations;
|
||||||
inode->i_fop = &fuse_dir_operations;
|
inode->i_fop = &fuse_dir_operations;
|
||||||
|
|
||||||
|
spin_lock_init(&fi->rdc.lock);
|
||||||
|
fi->rdc.cached = false;
|
||||||
|
fi->rdc.size = 0;
|
||||||
|
fi->rdc.pos = 0;
|
||||||
|
fi->rdc.version = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fuse_init_symlink(struct inode *inode)
|
void fuse_init_symlink(struct inode *inode)
|
||||||
|
|
|
@ -3143,6 +3143,14 @@ static const struct address_space_operations fuse_file_aops = {
|
||||||
|
|
||||||
void fuse_init_file_inode(struct inode *inode)
|
void fuse_init_file_inode(struct inode *inode)
|
||||||
{
|
{
|
||||||
|
struct fuse_inode *fi = get_fuse_inode(inode);
|
||||||
|
|
||||||
inode->i_fop = &fuse_file_operations;
|
inode->i_fop = &fuse_file_operations;
|
||||||
inode->i_data.a_ops = &fuse_file_aops;
|
inode->i_data.a_ops = &fuse_file_aops;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&fi->write_files);
|
||||||
|
INIT_LIST_HEAD(&fi->queued_writes);
|
||||||
|
fi->writectr = 0;
|
||||||
|
init_waitqueue_head(&fi->page_waitq);
|
||||||
|
INIT_LIST_HEAD(&fi->writepages);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,45 +87,51 @@ struct fuse_inode {
|
||||||
/** Version of last attribute change */
|
/** Version of last attribute change */
|
||||||
u64 attr_version;
|
u64 attr_version;
|
||||||
|
|
||||||
/** Files usable in writepage. Protected by fc->lock */
|
union {
|
||||||
struct list_head write_files;
|
/* Write related fields (regular file only) */
|
||||||
|
struct {
|
||||||
|
/* Files usable in writepage. Protected by fc->lock */
|
||||||
|
struct list_head write_files;
|
||||||
|
|
||||||
/** Writepages pending on truncate or fsync */
|
/* Writepages pending on truncate or fsync */
|
||||||
struct list_head queued_writes;
|
struct list_head queued_writes;
|
||||||
|
|
||||||
/** Number of sent writes, a negative bias (FUSE_NOWRITE)
|
/* Number of sent writes, a negative bias
|
||||||
* means more writes are blocked */
|
* (FUSE_NOWRITE) means more writes are blocked */
|
||||||
int writectr;
|
int writectr;
|
||||||
|
|
||||||
/** Waitq for writepage completion */
|
/* Waitq for writepage completion */
|
||||||
wait_queue_head_t page_waitq;
|
wait_queue_head_t page_waitq;
|
||||||
|
|
||||||
/** List of writepage requestst (pending or sent) */
|
/* List of writepage requestst (pending or sent) */
|
||||||
struct list_head writepages;
|
struct list_head writepages;
|
||||||
|
};
|
||||||
|
|
||||||
/* readdir cache */
|
/* readdir cache (directory only) */
|
||||||
struct {
|
struct {
|
||||||
/* true if fully cached */
|
/* true if fully cached */
|
||||||
bool cached;
|
bool cached;
|
||||||
|
|
||||||
/* size of cache */
|
/* size of cache */
|
||||||
loff_t size;
|
loff_t size;
|
||||||
|
|
||||||
/* position at end of cache (position of next entry) */
|
/* position at end of cache (position of next entry) */
|
||||||
loff_t pos;
|
loff_t pos;
|
||||||
|
|
||||||
/* version of the cache */
|
/* version of the cache */
|
||||||
u64 version;
|
u64 version;
|
||||||
|
|
||||||
/* modification time of directory when cache was started */
|
/* modification time of directory when cache was
|
||||||
struct timespec64 mtime;
|
* started */
|
||||||
|
struct timespec64 mtime;
|
||||||
|
|
||||||
/* iversion of directory when cache was started */
|
/* iversion of directory when cache was started */
|
||||||
u64 iversion;
|
u64 iversion;
|
||||||
|
|
||||||
/* protects above fields */
|
/* protects above fields */
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
} rdc;
|
} rdc;
|
||||||
|
};
|
||||||
|
|
||||||
/** Miscellaneous bits describing inode state */
|
/** Miscellaneous bits describing inode state */
|
||||||
unsigned long state;
|
unsigned long state;
|
||||||
|
|
|
@ -93,18 +93,8 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
|
||||||
fi->nodeid = 0;
|
fi->nodeid = 0;
|
||||||
fi->nlookup = 0;
|
fi->nlookup = 0;
|
||||||
fi->attr_version = 0;
|
fi->attr_version = 0;
|
||||||
fi->writectr = 0;
|
|
||||||
fi->orig_ino = 0;
|
fi->orig_ino = 0;
|
||||||
fi->state = 0;
|
fi->state = 0;
|
||||||
INIT_LIST_HEAD(&fi->write_files);
|
|
||||||
INIT_LIST_HEAD(&fi->queued_writes);
|
|
||||||
INIT_LIST_HEAD(&fi->writepages);
|
|
||||||
init_waitqueue_head(&fi->page_waitq);
|
|
||||||
spin_lock_init(&fi->rdc.lock);
|
|
||||||
fi->rdc.cached = false;
|
|
||||||
fi->rdc.size = 0;
|
|
||||||
fi->rdc.pos = 0;
|
|
||||||
fi->rdc.version = 0;
|
|
||||||
mutex_init(&fi->mutex);
|
mutex_init(&fi->mutex);
|
||||||
fi->forget = fuse_alloc_forget();
|
fi->forget = fuse_alloc_forget();
|
||||||
if (!fi->forget) {
|
if (!fi->forget) {
|
||||||
|
@ -124,8 +114,10 @@ static void fuse_i_callback(struct rcu_head *head)
|
||||||
static void fuse_destroy_inode(struct inode *inode)
|
static void fuse_destroy_inode(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct fuse_inode *fi = get_fuse_inode(inode);
|
struct fuse_inode *fi = get_fuse_inode(inode);
|
||||||
BUG_ON(!list_empty(&fi->write_files));
|
if (S_ISREG(inode->i_mode)) {
|
||||||
BUG_ON(!list_empty(&fi->queued_writes));
|
WARN_ON(!list_empty(&fi->write_files));
|
||||||
|
WARN_ON(!list_empty(&fi->queued_writes));
|
||||||
|
}
|
||||||
mutex_destroy(&fi->mutex);
|
mutex_destroy(&fi->mutex);
|
||||||
kfree(fi->forget);
|
kfree(fi->forget);
|
||||||
call_rcu(&inode->i_rcu, fuse_i_callback);
|
call_rcu(&inode->i_rcu, fuse_i_callback);
|
||||||
|
|
Loading…
Reference in New Issue