diff options
author | Brian Behlendorf <[email protected]> | 2014-07-15 13:29:57 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-07-17 15:15:07 -0700 |
commit | 1e8db7710220332808920a582e5794d6fc37b109 (patch) | |
tree | 5480855f5bc841e32703bc7cf4f0835b212f3077 /module/zfs/zfs_znode.c | |
parent | a5778ea2427bd340e3b4f697d9b6e1452bd71909 (diff) |
Fix zil_commit() NULL dereference
Update the current code to ensure inodes are never dirtied if they are
part of a read-only file system or snapshot. If they do somehow get
dirtied an attempt will make made to write them to disk. In the case
of snapshots, which don't have a ZIL, this will result in a NULL
dereference in zil_commit().
Signed-off-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #2405
Diffstat (limited to 'module/zfs/zfs_znode.c')
-rw-r--r-- | module/zfs/zfs_znode.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index 8cd0d8379..23e090712 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -511,6 +511,21 @@ zfs_inode_update(znode_t *zp) spin_unlock(&ip->i_lock); } +/* + * Safely mark an inode dirty. Inodes which are part of a read-only + * file system or snapshot may not be dirtied. + */ +void +zfs_mark_inode_dirty(struct inode *ip) +{ + zfs_sb_t *zsb = ITOZSB(ip); + + if (zfs_is_readonly(zsb) || dmu_objset_is_snapshot(zsb->z_os)) + return; + + mark_inode_dirty(ip); +} + static uint64_t empty_xattr; static uint64_t pad[4]; static zfs_acl_phys_t acl_phys; |