cregit-Linux how code gets into the kernel

Release 4.11 fs/jfs/inode.c

Directory: fs/jfs
/*
 *   Copyright (C) International Business Machines Corp., 2000-2004
 *   Portions Copyright (C) Christoph Hellwig, 2001-2002
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#include <linux/fs.h>
#include <linux/mpage.h>
#include <linux/buffer_head.h>
#include <linux/pagemap.h>
#include <linux/quotaops.h>
#include <linux/uio.h>
#include <linux/writeback.h>
#include "jfs_incore.h"
#include "jfs_inode.h"
#include "jfs_filsys.h"
#include "jfs_imap.h"
#include "jfs_extent.h"
#include "jfs_unicode.h"
#include "jfs_debug.h"



struct inode *jfs_iget(struct super_block *sb, unsigned long ino) { 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); } 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; inode_nohighmem(inode); inode->i_mapping->a_ops = &jfs_aops; } else { inode->i_op = &jfs_fast_symlink_inode_operations; inode->i_link = JFS_IP(inode)->i_inline; /* * The inline data should be null-terminated, but * don't let on-disk corruption crash the kernel */ inode->i_link[inode->i_size] = '\0'; } } else { inode->i_op = &jfs_file_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); } unlock_new_inode(inode); return inode; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp16264.29%654.55%
David Howells7429.37%19.09%
Al Viro145.56%218.18%
Christoph Hellwig10.40%19.09%
Dmitriy Monakhov10.40%19.09%
Total252100.00%11100.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) { jfs_err("jfs_commit_inode(0x%p) called on read-only volume", inode); jfs_err("Is remount racy?"); noisy--; } return 0; } tid = txBegin(inode->i_sb, COMMIT_INODE); mutex_lock(&JFS_IP(inode)->commit_mutex); /* * Retest inode state after taking commit_mutex */ if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode)) rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0); txEnd(tid); mutex_unlock(&JFS_IP(inode)->commit_mutex); return rc; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp16396.45%466.67%
Ingo Molnar52.96%116.67%
Joe Perches10.59%116.67%
Total169100.00%6100.00%


int jfs_write_inode(struct inode *inode, struct writeback_control *wbc) { int wait = wbc->sync_mode == WB_SYNC_ALL; if (inode->i_nlink == 0) 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. */ if (!test_cflag(COMMIT_Dirty, inode)) { /* Make sure committed changes hit the disk */ jfs_flush_journal(JFS_SBI(inode->i_sb)->log, wait); return 0; } if (jfs_commit_inode(inode, wait)) { jfs_err("jfs_write_inode: jfs_commit_inode failed!"); return -EIO; } else return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp6268.89%466.67%
Andrey V. Savochkin1516.67%116.67%
Christoph Hellwig1314.44%116.67%
Total90100.00%6100.00%


void jfs_evict_inode(struct inode *inode) { jfs_info("In jfs_evict_inode, inode = 0x%p", inode); if (!inode->i_nlink && !is_bad_inode(inode)) { dquot_initialize(inode); if (JFS_IP(inode)->fileset == FILESYSTEM_I) { truncate_inode_pages_final(&inode->i_data); if (test_cflag(COMMIT_Freewmap, inode)) jfs_free_zero_link(inode); diFree(inode); /* * Free the inode from the quota allocation. */ dquot_initialize(inode); dquot_free_inode(inode); } } else { truncate_inode_pages_final(&inode->i_data); } clear_inode(inode); dquot_drop(inode); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp6862.39%646.15%
Al Viro2119.27%17.69%
Christoph Hellwig109.17%323.08%
Mark Fasheh76.42%17.69%
Johannes Weiner21.83%17.69%
Jan Kara10.92%17.69%
Total109100.00%13100.00%


void jfs_dirty_inode(struct inode *inode, int flags) { 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); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp6195.31%266.67%
Christoph Hellwig34.69%133.33%
Total64100.00%3100.00%


int jfs_get_block(struct inode *ip, sector_t lblock, struct buffer_head *bh_result, int create) { s64 lblock64 = lblock; int rc = 0; xad_t xad; s64 xaddr; int xflag; s32 xlen = bh_result->b_size >> ip->i_blkbits; /* * Take appropriate lock on inode */ if (create) IWRITE_LOCK(ip, RDWRLOCK_NORMAL); else IREAD_LOCK(ip, RDWRLOCK_NORMAL); if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) && (!xtLookup(ip, lblock64, xlen, &xflag, &xaddr, &xlen, 0)) && xaddr) { if (xflag & XAD_NOTRECORDED) { if (!create) /* * Allocated but not recorded, read treats * this as a hole */ goto unlock; #ifdef _JFS_4K XADoffset(&xad, lblock64); XADlength(&xad, xlen); XADaddress(&xad, xaddr); #else /* _JFS_4K */ /* * As long as block size = 4K, this isn't a problem. * We should mark the whole page not ABNR, but how * will we know to mark the other blocks BH_New? */ BUG(); #endif /* _JFS_4K */ 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 */ #ifdef _JFS_4K if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, &xad))) goto unlock; rc = extAlloc(ip, xlen, lblock64, &xad, false); 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; #else /* _JFS_4K */ /* * We need to do whatever it takes to keep all but the last buffers * in 4K pages - see jfs_write.c */ BUG(); #endif /* _JFS_4K */ unlock: /* * Release lock on inode */ if (create) IWRITE_UNLOCK(ip); else IREAD_UNLOCK(ip); return rc; }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp33497.95%777.78%
Andrew Morton61.76%111.11%
Richard Knutsson10.29%111.11%
Total341100.00%9100.00%


static int jfs_writepage(struct page *page, struct writeback_control *wbc) { return block_write_full_page(page, jfs_get_block, wbc); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp1869.23%133.33%
Andrew Morton726.92%133.33%
Nicholas Piggin13.85%133.33%
Total26100.00%3100.00%


static int jfs_writepages(struct address_space *mapping, struct writeback_control *wbc) { return mpage_writepages(mapping, wbc, jfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp2284.62%150.00%
Andrew Morton415.38%150.00%
Total26100.00%2100.00%


static int jfs_readpage(struct file *file, struct page *page) { return mpage_readpage(page, jfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp24100.00%2100.00%
Total24100.00%2100.00%


static int jfs_readpages(struct file *file, struct address_space *mapping, struct list_head *pages, unsigned nr_pages) { return mpage_readpages(mapping, pages, nr_pages, jfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp3186.11%150.00%
Trond Myklebust513.89%150.00%
Total36100.00%2100.00%


static void jfs_write_failed(struct address_space *mapping, loff_t to) { struct inode *inode = mapping->host; if (to > inode->i_size) { truncate_pagecache(inode, inode->i_size); jfs_truncate(inode); } }

Contributors

PersonTokensPropCommitsCommitProp
Marco Stornelli47100.00%1100.00%
Total47100.00%1100.00%


static int jfs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) { int ret; ret = nobh_write_begin(mapping, pos, len, flags, pagep, fsdata, jfs_get_block); if (unlikely(ret)) jfs_write_failed(mapping, pos + len); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Nicholas Piggin3038.96%240.00%
Dave Kleikamp2329.87%120.00%
Christoph Hellwig2127.27%120.00%
Marco Stornelli33.90%120.00%
Total77100.00%5100.00%


static sector_t jfs_bmap(struct address_space *mapping, sector_t block) { return generic_block_bmap(mapping, block, jfs_get_block); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp2291.67%150.00%
Andrew Morton28.33%150.00%
Total24100.00%2100.00%


static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { struct file *file = iocb->ki_filp; struct address_space *mapping = file->f_mapping; struct inode *inode = file->f_mapping->host; size_t count = iov_iter_count(iter); ssize_t ret; ret = blockdev_direct_IO(iocb, inode, iter, jfs_get_block); /* * In case of error extending write may have instantiated a few * blocks outside i_size. Trim these off again. */ if (unlikely(iov_iter_rw(iter) == WRITE && ret < 0)) { loff_t isize = i_size_read(inode); loff_t end = iocb->ki_pos + count; if (end > isize) jfs_write_failed(mapping, end); } return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig4839.67%215.38%
Andrew Morton1714.05%430.77%
Dave Kleikamp1613.22%17.69%
Al Viro129.92%215.38%
Marco Stornelli129.92%17.69%
Chuck Lever108.26%17.69%
Omar Sandoval54.13%17.69%
Badari Pulavarty10.83%17.69%
Total121100.00%13100.00%

const struct address_space_operations jfs_aops = { .readpage = jfs_readpage, .readpages = jfs_readpages, .writepage = jfs_writepage, .writepages = jfs_writepages, .write_begin = jfs_write_begin, .write_end = nobh_write_end, .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); /* * The commit_mutex cannot be taken before txBegin. * txBegin may block and there is a chance the inode * could be marked dirty and need to be committed * before txBegin unblocks */ mutex_lock(&JFS_IP(ip)->commit_mutex); newsize = xtTruncate(tid, ip, length, COMMIT_TRUNCATE | COMMIT_PWMAP); if (newsize < 0) { txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); break; } ip->i_mtime = ip->i_ctime = current_time(ip); mark_inode_dirty(ip); txCommit(tid, 1, &ip, 0); txEnd(tid); mutex_unlock(&JFS_IP(ip)->commit_mutex); } while (newsize > length); /* Truncate isn't always atomic */ }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp15893.49%133.33%
Ingo Molnar74.14%133.33%
Deepa Dinamani42.37%133.33%
Total169100.00%3100.00%


void jfs_truncate(struct inode *ip) { jfs_info("jfs_truncate: size = 0x%lx", (ulong) ip->i_size); nobh_truncate_page(ip->i_mapping, ip->i_size, jfs_get_block); IWRITE_LOCK(ip, RDWRLOCK_NORMAL); jfs_truncate_nolock(ip, ip->i_size); IWRITE_UNLOCK(ip); }

Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp5394.64%360.00%
Nicholas Piggin35.36%240.00%
Total56100.00%5100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Dave Kleikamp129274.99%2536.23%
Christoph Hellwig1046.04%1217.39%
David Howells744.29%11.45%
Marco Stornelli623.60%11.45%
Al Viro472.73%57.25%
Andrew Morton392.26%913.04%
Nicholas Piggin382.21%22.90%
Andrey V. Savochkin150.87%11.45%
Ingo Molnar120.70%11.45%
Chuck Lever100.58%11.45%
Mark Fasheh70.41%11.45%
Trond Myklebust50.29%11.45%
Omar Sandoval50.29%11.45%
Deepa Dinamani40.23%11.45%
Kent Overstreet20.12%11.45%
Johannes Weiner20.12%11.45%
Dmitriy Monakhov10.06%11.45%
Jan Kara10.06%11.45%
Badari Pulavarty10.06%11.45%
Richard Knutsson10.06%11.45%
Joe Perches10.06%11.45%
Total1723100.00%69100.00%
Directory: fs/jfs
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.