atomic_t i_opencnt was used to free allocation in case there were no more opens. This patch replaces affs_file_open by generic_file_open and uses FMODE_WRITE/i_writecount==1 for the task like other FS.
Reviewed-by: Jan Kara <j...@suse.cz> Cc: Andrew Morton <a...@linux-foundation.org> Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/affs.h | 1 - fs/affs/file.c | 17 ++++------------- fs/affs/inode.c | 2 -- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index ff44ff3..c50815f 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -39,7 +39,6 @@ struct affs_ext_key { * affs fs inode data in memory */ struct affs_inode_info { - atomic_t i_opencnt; struct semaphore i_link_lock; /* Protects internal inode access. */ struct semaphore i_ext_lock; /* Protects internal inode access. */ #define i_hash_lock i_ext_lock diff --git a/fs/affs/file.c b/fs/affs/file.c index d2468bf..77e30e8 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -18,21 +18,12 @@ static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext); static int -affs_file_open(struct inode *inode, struct file *filp) -{ - pr_debug("open(%lu,%d)\n", - inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); - atomic_inc(&AFFS_I(inode)->i_opencnt); - return 0; -} - -static int affs_file_release(struct inode *inode, struct file *filp) { - pr_debug("release(%lu, %d)\n", - inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt)); + pr_debug("release(%lu)\n", inode->i_ino); - if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) { + if ((filp->f_mode & FMODE_WRITE) && + (atomic_read(&inode->i_writecount) == 1)) { mutex_lock(&inode->i_mutex); if (inode->i_size != AFFS_I(inode)->mmu_private) affs_truncate(inode); @@ -969,7 +960,7 @@ const struct file_operations affs_file_operations = { .write = new_sync_write, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .open = affs_file_open, + .open = generic_file_open, .release = affs_file_release, .fsync = affs_file_fsync, .splice_read = generic_file_splice_read, diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 25cb4b4..5c160dd 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -56,7 +56,6 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino) AFFS_I(inode)->i_extcnt = 1; AFFS_I(inode)->i_ext_last = ~1; AFFS_I(inode)->i_protect = prot; - atomic_set(&AFFS_I(inode)->i_opencnt, 0); AFFS_I(inode)->i_blkcnt = 0; AFFS_I(inode)->i_lc = NULL; AFFS_I(inode)->i_lc_size = 0; @@ -307,7 +306,6 @@ affs_new_inode(struct inode *dir) inode->i_ino = block; set_nlink(inode, 1); inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; - atomic_set(&AFFS_I(inode)->i_opencnt, 0); AFFS_I(inode)->i_blkcnt = 0; AFFS_I(inode)->i_lc = NULL; AFFS_I(inode)->i_lc_size = 0; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/