2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) International Business Machines Corp., 2000-2004
|
|
|
|
* Portions Copyright (C) Christoph Hellwig, 2001-2002
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mpage.h>
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/quotaops.h>
|
2015-02-23 00:58:50 +08:00
|
|
|
#include <linux/uio.h>
|
2010-03-05 16:21:37 +08:00
|
|
|
#include <linux/writeback.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "jfs_incore.h"
|
2005-05-05 04:29:35 +08:00
|
|
|
#include "jfs_inode.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "jfs_filsys.h"
|
|
|
|
#include "jfs_imap.h"
|
|
|
|
#include "jfs_extent.h"
|
|
|
|
#include "jfs_unicode.h"
|
|
|
|
#include "jfs_debug.h"
|
2019-04-16 10:48:59 +08:00
|
|
|
#include "jfs_dmap.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
2008-02-07 16:15:43 +08:00
|
|
|
struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-02-07 16:15:43 +08:00
|
|
|
struct inode *inode;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
inode = iget_locked(sb, ino);
|
|
|
|
if (!inode)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
if (!(inode->i_state & I_NEW))
|
|
|
|
return inode;
|
|
|
|
|
|
|
|
ret = diRead(inode);
|
|
|
|
if (ret < 0) {
|
|
|
|
iget_failed(inode);
|
|
|
|
return ERR_PTR(ret);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (S_ISREG(inode->i_mode)) {
|
|
|
|
inode->i_op = &jfs_file_inode_operations;
|
|
|
|
inode->i_fop = &jfs_file_operations;
|
|
|
|
inode->i_mapping->a_ops = &jfs_aops;
|
|
|
|
} else if (S_ISDIR(inode->i_mode)) {
|
|
|
|
inode->i_op = &jfs_dir_inode_operations;
|
|
|
|
inode->i_fop = &jfs_dir_operations;
|
|
|
|
} else if (S_ISLNK(inode->i_mode)) {
|
|
|
|
if (inode->i_size >= IDATASIZE) {
|
|
|
|
inode->i_op = &page_symlink_inode_operations;
|
2015-11-17 14:07:57 +08:00
|
|
|
inode_nohighmem(inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
inode->i_mapping->a_ops = &jfs_aops;
|
2008-12-17 00:21:34 +08:00
|
|
|
} else {
|
2010-04-16 21:05:50 +08:00
|
|
|
inode->i_op = &jfs_fast_symlink_inode_operations;
|
2015-05-02 22:41:20 +08:00
|
|
|
inode->i_link = JFS_IP(inode)->i_inline;
|
2008-12-17 00:21:34 +08:00
|
|
|
/*
|
|
|
|
* The inline data should be null-terminated, but
|
|
|
|
* don't let on-disk corruption crash the kernel
|
|
|
|
*/
|
2015-05-02 22:41:20 +08:00
|
|
|
inode->i_link[inode->i_size] = '\0';
|
2008-12-17 00:21:34 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
inode->i_op = &jfs_file_inode_operations;
|
|
|
|
init_special_inode(inode, inode->i_mode, inode->i_rdev);
|
|
|
|
}
|
2008-02-07 16:15:43 +08:00
|
|
|
unlock_new_inode(inode);
|
|
|
|
return inode;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Workhorse of both fsync & write_inode
|
|
|
|
*/
|
|
|
|
int jfs_commit_inode(struct inode *inode, int wait)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
tid_t tid;
|
|
|
|
static int noisy = 5;
|
|
|
|
|
|
|
|
jfs_info("In jfs_commit_inode, inode = 0x%p", inode);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't commit if inode has been committed since last being
|
|
|
|
* marked dirty, or if it has been deleted.
|
|
|
|
*/
|
|
|
|
if (inode->i_nlink == 0 || !test_cflag(COMMIT_Dirty, inode))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (isReadOnly(inode)) {
|
|
|
|
/* kernel allows writes to devices on read-only
|
|
|
|
* partitions and may think inode is dirty
|
|
|
|
*/
|
|
|
|
if (!special_file(inode->i_mode) && noisy) {
|
2016-03-30 20:23:18 +08:00
|
|
|
jfs_err("jfs_commit_inode(0x%p) called on read-only volume",
|
|
|
|
inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
jfs_err("Is remount racy?");
|
|
|
|
noisy--;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tid = txBegin(inode->i_sb, COMMIT_INODE);
|
2006-01-25 05:22:50 +08:00
|
|
|
mutex_lock(&JFS_IP(inode)->commit_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2006-01-25 05:22:50 +08:00
|
|
|
* Retest inode state after taking commit_mutex
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))
|
|
|
|
rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);
|
|
|
|
|
|
|
|
txEnd(tid);
|
2006-01-25 05:22:50 +08:00
|
|
|
mutex_unlock(&JFS_IP(inode)->commit_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-03-05 16:21:37 +08:00
|
|
|
int jfs_write_inode(struct inode *inode, struct writeback_control *wbc)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-03-05 16:21:37 +08:00
|
|
|
int wait = wbc->sync_mode == WB_SYNC_ALL;
|
|
|
|
|
2013-05-02 00:08:38 +08:00
|
|
|
if (inode->i_nlink == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* If COMMIT_DIRTY is not set, the inode isn't really dirty.
|
|
|
|
* It has been committed since the last change, but was still
|
|
|
|
* on the dirty inode list.
|
|
|
|
*/
|
2015-06-05 00:57:03 +08:00
|
|
|
if (!test_cflag(COMMIT_Dirty, inode)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Make sure committed changes hit the disk */
|
|
|
|
jfs_flush_journal(JFS_SBI(inode->i_sb)->log, wait);
|
|
|
|
return 0;
|
2015-06-05 00:57:03 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (jfs_commit_inode(inode, wait)) {
|
|
|
|
jfs_err("jfs_write_inode: jfs_commit_inode failed!");
|
|
|
|
return -EIO;
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
void jfs_evict_inode(struct inode *inode)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2019-04-16 10:48:59 +08:00
|
|
|
struct jfs_inode_info *ji = JFS_IP(inode);
|
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
jfs_info("In jfs_evict_inode, inode = 0x%p", inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
if (!inode->i_nlink && !is_bad_inode(inode)) {
|
2010-03-03 22:05:07 +08:00
|
|
|
dquot_initialize(inode);
|
2010-03-03 22:05:06 +08:00
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
|
2022-03-22 21:59:17 +08:00
|
|
|
struct inode *ipimap = JFS_SBI(inode->i_sb)->ipimap;
|
2014-04-04 05:47:49 +08:00
|
|
|
truncate_inode_pages_final(&inode->i_data);
|
2005-09-10 04:01:31 +08:00
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
if (test_cflag(COMMIT_Freewmap, inode))
|
|
|
|
jfs_free_zero_link(inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2022-03-22 21:59:17 +08:00
|
|
|
if (ipimap && JFS_IP(ipimap)->i_imap)
|
2021-06-06 22:24:05 +08:00
|
|
|
diFree(inode);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-06-07 12:28:54 +08:00
|
|
|
/*
|
|
|
|
* Free the inode from the quota allocation.
|
|
|
|
*/
|
|
|
|
dquot_free_inode(inode);
|
|
|
|
}
|
|
|
|
} else {
|
2014-04-04 05:47:49 +08:00
|
|
|
truncate_inode_pages_final(&inode->i_data);
|
2005-08-31 03:28:56 +08:00
|
|
|
}
|
2012-05-03 20:48:02 +08:00
|
|
|
clear_inode(inode);
|
2010-06-07 12:28:54 +08:00
|
|
|
dquot_drop(inode);
|
2019-04-16 10:48:59 +08:00
|
|
|
|
|
|
|
BUG_ON(!list_empty(&ji->anon_inode_list));
|
|
|
|
|
|
|
|
spin_lock_irq(&ji->ag_lock);
|
|
|
|
if (ji->active_ag != -1) {
|
|
|
|
struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
|
|
|
|
atomic_dec(&bmap->db_active[ji->active_ag]);
|
|
|
|
ji->active_ag = -1;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ji->ag_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2011-05-27 18:53:02 +08:00
|
|
|
void jfs_dirty_inode(struct inode *inode, int flags)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
static int noisy = 5;
|
|
|
|
|
|
|
|
if (isReadOnly(inode)) {
|
|
|
|
if (!special_file(inode->i_mode) && noisy) {
|
|
|
|
/* kernel allows writes to devices on read-only
|
|
|
|
* partitions and may try to mark inode dirty
|
|
|
|
*/
|
|
|
|
jfs_err("jfs_dirty_inode called on read-only volume");
|
|
|
|
jfs_err("Is remount racy?");
|
|
|
|
noisy--;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_cflag(COMMIT_Dirty, inode);
|
|
|
|
}
|
|
|
|
|
2006-07-27 03:52:13 +08:00
|
|
|
int jfs_get_block(struct inode *ip, sector_t lblock,
|
|
|
|
struct buffer_head *bh_result, int create)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
s64 lblock64 = lblock;
|
|
|
|
int rc = 0;
|
|
|
|
xad_t xad;
|
|
|
|
s64 xaddr;
|
|
|
|
int xflag;
|
2006-07-27 03:52:13 +08:00
|
|
|
s32 xlen = bh_result->b_size >> ip->i_blkbits;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Take appropriate lock on inode
|
|
|
|
*/
|
2005-05-03 02:25:02 +08:00
|
|
|
if (create)
|
2007-01-10 04:14:48 +08:00
|
|
|
IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
|
2005-05-03 02:25:02 +08:00
|
|
|
else
|
2007-01-10 04:14:48 +08:00
|
|
|
IREAD_LOCK(ip, RDWRLOCK_NORMAL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) &&
|
2006-07-27 03:52:13 +08:00
|
|
|
(!xtLookup(ip, lblock64, xlen, &xflag, &xaddr, &xlen, 0)) &&
|
2005-05-03 02:25:13 +08:00
|
|
|
xaddr) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (xflag & XAD_NOTRECORDED) {
|
|
|
|
if (!create)
|
|
|
|
/*
|
|
|
|
* Allocated but not recorded, read treats
|
|
|
|
* this as a hole
|
|
|
|
*/
|
|
|
|
goto unlock;
|
|
|
|
XADoffset(&xad, lblock64);
|
|
|
|
XADlength(&xad, xlen);
|
|
|
|
XADaddress(&xad, xaddr);
|
|
|
|
rc = extRecord(ip, &xad);
|
|
|
|
if (rc)
|
|
|
|
goto unlock;
|
|
|
|
set_buffer_new(bh_result);
|
|
|
|
}
|
|
|
|
|
|
|
|
map_bh(bh_result, ip->i_sb, xaddr);
|
|
|
|
bh_result->b_size = xlen << ip->i_blkbits;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
if (!create)
|
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a new block
|
|
|
|
*/
|
|
|
|
if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad)))
|
|
|
|
goto unlock;
|
2006-10-01 14:27:14 +08:00
|
|
|
rc = extAlloc(ip, xlen, lblock64, &xad, false);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (rc)
|
|
|
|
goto unlock;
|
|
|
|
|
|
|
|
set_buffer_new(bh_result);
|
|
|
|
map_bh(bh_result, ip->i_sb, addressXAD(&xad));
|
|
|
|
bh_result->b_size = lengthXAD(&xad) << ip->i_blkbits;
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
/*
|
|
|
|
* Release lock on inode
|
|
|
|
*/
|
2005-05-03 02:25:02 +08:00
|
|
|
if (create)
|
|
|
|
IWRITE_UNLOCK(ip);
|
|
|
|
else
|
|
|
|
IREAD_UNLOCK(ip);
|
2005-04-17 06:20:36 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int jfs_writepage(struct page *page, struct writeback_control *wbc)
|
|
|
|
{
|
2007-10-16 16:25:22 +08:00
|
|
|
return block_write_full_page(page, jfs_get_block, wbc);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int jfs_writepages(struct address_space *mapping,
|
|
|
|
struct writeback_control *wbc)
|
|
|
|
{
|
|
|
|
return mpage_writepages(mapping, wbc, jfs_get_block);
|
|
|
|
}
|
|
|
|
|
2022-04-29 23:47:39 +08:00
|
|
|
static int jfs_read_folio(struct file *file, struct folio *folio)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2022-04-29 23:47:39 +08:00
|
|
|
return mpage_read_folio(folio, jfs_get_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
fs: convert mpage_readpages to mpage_readahead
Implement the new readahead aop and convert all callers (block_dev,
exfat, ext2, fat, gfs2, hpfs, isofs, jfs, nilfs2, ocfs2, omfs, qnx6,
reiserfs & udf).
The callers are all trivial except for GFS2 & OCFS2.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com> # ocfs2
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> # ocfs2
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Link: http://lkml.kernel.org/r/20200414150233.24495-17-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-02 12:47:02 +08:00
|
|
|
static void jfs_readahead(struct readahead_control *rac)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
fs: convert mpage_readpages to mpage_readahead
Implement the new readahead aop and convert all callers (block_dev,
exfat, ext2, fat, gfs2, hpfs, isofs, jfs, nilfs2, ocfs2, omfs, qnx6,
reiserfs & udf).
The callers are all trivial except for GFS2 & OCFS2.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com> # ocfs2
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> # ocfs2
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Link: http://lkml.kernel.org/r/20200414150233.24495-17-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-02 12:47:02 +08:00
|
|
|
mpage_readahead(rac, jfs_get_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-12-15 18:54:25 +08:00
|
|
|
static void jfs_write_failed(struct address_space *mapping, loff_t to)
|
|
|
|
{
|
|
|
|
struct inode *inode = mapping->host;
|
|
|
|
|
|
|
|
if (to > inode->i_size) {
|
2013-09-13 06:13:56 +08:00
|
|
|
truncate_pagecache(inode, inode->i_size);
|
2012-12-15 18:54:25 +08:00
|
|
|
jfs_truncate(inode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-16 16:25:22 +08:00
|
|
|
static int jfs_write_begin(struct file *file, struct address_space *mapping,
|
2022-02-23 03:31:43 +08:00
|
|
|
loff_t pos, unsigned len,
|
2007-10-16 16:25:22 +08:00
|
|
|
struct page **pagep, void **fsdata)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-06-04 17:29:54 +08:00
|
|
|
int ret;
|
|
|
|
|
2022-02-23 00:54:56 +08:00
|
|
|
ret = nobh_write_begin(mapping, pos, len, pagep, fsdata, jfs_get_block);
|
2012-12-15 18:54:25 +08:00
|
|
|
if (unlikely(ret))
|
|
|
|
jfs_write_failed(mapping, pos + len);
|
2010-06-04 17:29:54 +08:00
|
|
|
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static sector_t jfs_bmap(struct address_space *mapping, sector_t block)
|
|
|
|
{
|
|
|
|
return generic_block_bmap(mapping, block, jfs_get_block);
|
|
|
|
}
|
|
|
|
|
2016-04-07 23:51:58 +08:00
|
|
|
static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct file *file = iocb->ki_filp;
|
2012-12-15 18:54:25 +08:00
|
|
|
struct address_space *mapping = file->f_mapping;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct inode *inode = file->f_mapping->host;
|
2014-03-05 11:38:00 +08:00
|
|
|
size_t count = iov_iter_count(iter);
|
2010-06-04 17:29:53 +08:00
|
|
|
ssize_t ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-04-07 23:51:58 +08:00
|
|
|
ret = blockdev_direct_IO(iocb, inode, iter, jfs_get_block);
|
2010-06-04 17:29:53 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* In case of error extending write may have instantiated a few
|
|
|
|
* blocks outside i_size. Trim these off again.
|
|
|
|
*/
|
2015-03-16 19:33:52 +08:00
|
|
|
if (unlikely(iov_iter_rw(iter) == WRITE && ret < 0)) {
|
2010-06-04 17:29:53 +08:00
|
|
|
loff_t isize = i_size_read(inode);
|
2016-04-07 23:51:58 +08:00
|
|
|
loff_t end = iocb->ki_pos + count;
|
2010-06-04 17:29:53 +08:00
|
|
|
|
|
|
|
if (end > isize)
|
2012-12-15 18:54:25 +08:00
|
|
|
jfs_write_failed(mapping, end);
|
2010-06-04 17:29:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-06-28 19:26:44 +08:00
|
|
|
const struct address_space_operations jfs_aops = {
|
2022-02-10 04:22:12 +08:00
|
|
|
.dirty_folio = block_dirty_folio,
|
2022-02-10 04:21:34 +08:00
|
|
|
.invalidate_folio = block_invalidate_folio,
|
2022-04-29 23:47:39 +08:00
|
|
|
.read_folio = jfs_read_folio,
|
fs: convert mpage_readpages to mpage_readahead
Implement the new readahead aop and convert all callers (block_dev,
exfat, ext2, fat, gfs2, hpfs, isofs, jfs, nilfs2, ocfs2, omfs, qnx6,
reiserfs & udf).
The callers are all trivial except for GFS2 & OCFS2.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com> # ocfs2
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> # ocfs2
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Link: http://lkml.kernel.org/r/20200414150233.24495-17-willy@infradead.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-02 12:47:02 +08:00
|
|
|
.readahead = jfs_readahead,
|
2005-04-17 06:20:36 +08:00
|
|
|
.writepage = jfs_writepage,
|
|
|
|
.writepages = jfs_writepages,
|
2007-10-16 16:25:22 +08:00
|
|
|
.write_begin = jfs_write_begin,
|
2007-10-16 16:25:25 +08:00
|
|
|
.write_end = nobh_write_end,
|
2005-04-17 06:20:36 +08:00
|
|
|
.bmap = jfs_bmap,
|
|
|
|
.direct_IO = jfs_direct_IO,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Guts of jfs_truncate. Called with locks already held. Can be called
|
|
|
|
* with directory for truncating directory index table.
|
|
|
|
*/
|
|
|
|
void jfs_truncate_nolock(struct inode *ip, loff_t length)
|
|
|
|
{
|
|
|
|
loff_t newsize;
|
|
|
|
tid_t tid;
|
|
|
|
|
|
|
|
ASSERT(length >= 0);
|
|
|
|
|
|
|
|
if (test_cflag(COMMIT_Nolink, ip)) {
|
|
|
|
xtTruncate(0, ip, length, COMMIT_WMAP);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
tid = txBegin(ip->i_sb, 0);
|
|
|
|
|
|
|
|
/*
|
2006-01-25 05:22:50 +08:00
|
|
|
* The commit_mutex cannot be taken before txBegin.
|
2005-04-17 06:20:36 +08:00
|
|
|
* txBegin may block and there is a chance the inode
|
|
|
|
* could be marked dirty and need to be committed
|
|
|
|
* before txBegin unblocks
|
|
|
|
*/
|
2006-01-25 05:22:50 +08:00
|
|
|
mutex_lock(&JFS_IP(ip)->commit_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
newsize = xtTruncate(tid, ip, length,
|
|
|
|
COMMIT_TRUNCATE | COMMIT_PWMAP);
|
|
|
|
if (newsize < 0) {
|
|
|
|
txEnd(tid);
|
2006-01-25 05:22:50 +08:00
|
|
|
mutex_unlock(&JFS_IP(ip)->commit_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-14 22:48:04 +08:00
|
|
|
ip->i_mtime = ip->i_ctime = current_time(ip);
|
2005-04-17 06:20:36 +08:00
|
|
|
mark_inode_dirty(ip);
|
|
|
|
|
|
|
|
txCommit(tid, 1, &ip, 0);
|
|
|
|
txEnd(tid);
|
2006-01-25 05:22:50 +08:00
|
|
|
mutex_unlock(&JFS_IP(ip)->commit_mutex);
|
2005-04-17 06:20:36 +08:00
|
|
|
} while (newsize > length); /* Truncate isn't always atomic */
|
|
|
|
}
|
|
|
|
|
|
|
|
void jfs_truncate(struct inode *ip)
|
|
|
|
{
|
|
|
|
jfs_info("jfs_truncate: size = 0x%lx", (ulong) ip->i_size);
|
|
|
|
|
2007-10-16 16:25:25 +08:00
|
|
|
nobh_truncate_page(ip->i_mapping, ip->i_size, jfs_get_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-01-10 04:14:48 +08:00
|
|
|
IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
|
2005-04-17 06:20:36 +08:00
|
|
|
jfs_truncate_nolock(ip, ip->i_size);
|
|
|
|
IWRITE_UNLOCK(ip);
|
|
|
|
}
|