Skip to content

Commit

Permalink
wip: write_inode
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
  • Loading branch information
snajpa committed Dec 1, 2024
1 parent 54ec6e9 commit 9a45786
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/os/linux/zfs/sys/zpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extern const struct inode_operations zpl_special_inode_operations;
extern const struct address_space_operations zpl_address_space_operations;
extern const struct file_operations zpl_file_operations;
extern const struct file_operations zpl_dir_file_operations;
extern int zpl_writepages(struct address_space *mapping,
struct writeback_control *wbc);

/* zpl_super.c */
extern void zpl_prune_sb(uint64_t nr_to_scan, void *arg);
Expand Down
2 changes: 1 addition & 1 deletion module/os/linux/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ zpl_write_cache_pages(struct address_space *mapping,
return (result);
}

static int
int
zpl_writepages(struct address_space *mapping, struct writeback_control *wbc)
{
znode_t *zp = ITOZ(mapping->host);
Expand Down
27 changes: 26 additions & 1 deletion module/os/linux/zfs/zpl_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,31 @@ zpl_prune_sb(uint64_t nr_to_scan, void *arg)

}

static int
zpl_write_inode(struct inode *ip, struct writeback_control *wbc)
{
int error = 0;

// TODO: readonly bail early
/*
* Mark inode dirty if this is non-blocking call and there are
* tagged pages in the page cache.
*/
if ((wbc->sync_mode == WB_SYNC_NONE) &&
mapping_tagged(ip->i_mapping, PAGECACHE_TAG_WRITEBACK)) {
__mark_inode_dirty(ip, I_DIRTY_DATASYNC);
return (0);
}

error = zpl_writepages(ip->i_mapping, wbc);

if (!error)
return (0);

__mark_inode_dirty(ip, I_DIRTY_SYNC);
return (error);
}

const struct super_operations zpl_super_operations = {
.alloc_inode = zpl_inode_alloc,
#ifdef HAVE_INODE_FREE
Expand All @@ -406,7 +431,7 @@ const struct super_operations zpl_super_operations = {
.destroy_inode = zpl_inode_destroy,
#endif
.dirty_inode = zpl_dirty_inode,
.write_inode = NULL,
.write_inode = zpl_write_inode,
.evict_inode = zpl_evict_inode,
.put_super = zpl_put_super,
.sync_fs = zpl_sync_fs,
Expand Down

0 comments on commit 9a45786

Please sign in to comment.