Commit f5404e21 authored by Stephen Lord's avatar Stephen Lord

Use i_size_read and i_size_write instead of direct access to the i_size

field.
parent 9d76c64d
...@@ -133,7 +133,7 @@ map_blocks( ...@@ -133,7 +133,7 @@ map_blocks(
int error, nmaps = 1; int error, nmaps = 1;
if (((flags & (BMAP_DIRECT|BMAP_SYNC)) == BMAP_DIRECT) && if (((flags & (BMAP_DIRECT|BMAP_SYNC)) == BMAP_DIRECT) &&
(offset >= inode->i_size)) (offset >= i_size_read(inode)))
count = max_t(ssize_t, count, XFS_WRITE_IO_LOG); count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
retry: retry:
VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error); VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error);
...@@ -310,7 +310,7 @@ probe_unmapped_cluster( ...@@ -310,7 +310,7 @@ probe_unmapped_cluster(
struct buffer_head *bh, struct buffer_head *bh,
struct buffer_head *head) struct buffer_head *head)
{ {
unsigned long tindex, tlast; unsigned long tindex, tlast, tloop;
unsigned int len, total = 0; unsigned int len, total = 0;
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
...@@ -325,20 +325,22 @@ probe_unmapped_cluster( ...@@ -325,20 +325,22 @@ probe_unmapped_cluster(
* following pages. * following pages.
*/ */
if (bh == head) { if (bh == head) {
tlast = inode->i_size >> PAGE_CACHE_SHIFT; tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
/* Prune this back to avoid pathological behavior */ /* Prune this back to avoid pathological behavior */
tlast = min(tlast, startpage->index + 64); tloop = min(tlast, startpage->index + 64);
for (tindex = startpage->index + 1; tindex < tlast; tindex++) { for (tindex = startpage->index + 1; tindex < tloop; tindex++) {
len = probe_unmapped_page(mapping, tindex, len = probe_unmapped_page(mapping, tindex,
PAGE_CACHE_SIZE); PAGE_CACHE_SIZE);
if (!len) if (!len)
break; return total;
total += len; total += len;
} }
if ((tindex == tlast) && (inode->i_size & ~PAGE_CACHE_MASK)) { if (tindex == tlast) {
len = probe_unmapped_page(mapping, tindex, unsigned offset = i_size_read(inode) & (PAGE_CACHE_SIZE - 1);
inode->i_size & ~PAGE_CACHE_MASK); if (offset) {
total += len; total += probe_unmapped_page(mapping,
tindex, offset);
}
} }
} }
return total; return total;
...@@ -455,12 +457,12 @@ map_unwritten( ...@@ -455,12 +457,12 @@ map_unwritten(
*/ */
if (bh == head) { if (bh == head) {
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
unsigned long tindex, tlast, bs; unsigned long tindex, tloop, tlast, bs;
struct page *page; struct page *page;
tlast = inode->i_size >> PAGE_CACHE_SHIFT; tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
tlast = min(tlast, start_page->index + pb->pb_page_count - 1); tloop = min(tlast, start_page->index + pb->pb_page_count - 1);
for (tindex = start_page->index + 1; tindex < tlast; tindex++) { for (tindex = start_page->index + 1; tindex < tloop; tindex++) {
page = probe_unwritten_page(mapping, tindex, mp, pb, page = probe_unwritten_page(mapping, tindex, mp, pb,
PAGE_CACHE_SIZE, &bs); PAGE_CACHE_SIZE, &bs);
if (!page) if (!page)
...@@ -470,9 +472,9 @@ map_unwritten( ...@@ -470,9 +472,9 @@ map_unwritten(
convert_page(inode, page, mp, pb, 1, all_bh); convert_page(inode, page, mp, pb, 1, all_bh);
} }
if ((tindex == tlast) && (inode->i_size & ~PAGE_CACHE_MASK)) { if ((tindex == tlast) && (i_size_read(inode) & ~PAGE_CACHE_MASK)) {
page = probe_unwritten_page(mapping, tindex, mp, pb, page = probe_unwritten_page(mapping, tindex, mp, pb,
inode->i_size & ~PAGE_CACHE_MASK, &bs); i_size_read(inode) & ~PAGE_CACHE_MASK, &bs);
if (page) { if (page) {
nblocks += bs; nblocks += bs;
atomic_add(bs, &pb->pb_io_remaining); atomic_add(bs, &pb->pb_io_remaining);
...@@ -549,11 +551,11 @@ convert_page( ...@@ -549,11 +551,11 @@ convert_page(
int i = 0, index = 0; int i = 0, index = 0;
int bbits = inode->i_blkbits; int bbits = inode->i_blkbits;
end_index = inode->i_size >> PAGE_CACHE_SHIFT; end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
if (page->index < end_index) { if (page->index < end_index) {
end = PAGE_CACHE_SIZE; end = PAGE_CACHE_SIZE;
} else { } else {
end = inode->i_size & (PAGE_CACHE_SIZE-1); end = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
} }
bh = head = page_buffers(page); bh = head = page_buffers(page);
do { do {
...@@ -665,9 +667,9 @@ page_state_convert( ...@@ -665,9 +667,9 @@ page_state_convert(
/* Are we off the end of the file ? */ /* Are we off the end of the file ? */
end_index = inode->i_size >> PAGE_CACHE_SHIFT; end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
if (page->index >= end_index) { if (page->index >= end_index) {
unsigned remaining = inode->i_size & (PAGE_CACHE_SIZE-1); unsigned remaining = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
if ((page->index >= end_index+1) || !remaining) { if ((page->index >= end_index+1) || !remaining) {
return -EIO; return -EIO;
} }
...@@ -675,8 +677,8 @@ page_state_convert( ...@@ -675,8 +677,8 @@ page_state_convert(
offset = (loff_t)page->index << PAGE_CACHE_SHIFT; offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
end_offset = offset + PAGE_CACHE_SIZE; end_offset = offset + PAGE_CACHE_SIZE;
if (end_offset > inode->i_size) if (end_offset > i_size_read(inode))
end_offset = inode->i_size; end_offset = i_size_read(inode);
bh = head = page_buffers(page); bh = head = page_buffers(page);
mp = NULL; mp = NULL;
...@@ -855,7 +857,7 @@ linvfs_get_block_core( ...@@ -855,7 +857,7 @@ linvfs_get_block_core(
*/ */
if (blocks) if (blocks)
size = blocks << inode->i_blkbits; size = blocks << inode->i_blkbits;
else if (create && (offset >= inode->i_size)) else if (create && (offset >= i_size_read(inode)))
size = 1 << XFS_WRITE_IO_LOG; size = 1 << XFS_WRITE_IO_LOG;
else else
size = 1 << inode->i_blkbits; size = 1 << inode->i_blkbits;
...@@ -903,7 +905,7 @@ linvfs_get_block_core( ...@@ -903,7 +905,7 @@ linvfs_get_block_core(
*/ */
if (create && if (create &&
((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
(offset >= inode->i_size) || (pbmap.pbm_flags & PBMF_NEW))) { (offset >= i_size_read(inode)) || (pbmap.pbm_flags & PBMF_NEW))) {
set_buffer_new(bh_result); set_buffer_new(bh_result);
} }
......
...@@ -180,7 +180,7 @@ linvfs_open( ...@@ -180,7 +180,7 @@ linvfs_open(
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
int error; int error;
if (!(filp->f_flags & O_LARGEFILE) && inode->i_size > MAX_NON_LFS) if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EFBIG; return -EFBIG;
ASSERT(vp); ASSERT(vp);
......
...@@ -178,7 +178,7 @@ xfs_revalidate_inode( ...@@ -178,7 +178,7 @@ xfs_revalidate_inode(
} }
inode->i_blksize = PAGE_CACHE_SIZE; inode->i_blksize = PAGE_CACHE_SIZE;
inode->i_generation = ip->i_d.di_gen; inode->i_generation = ip->i_d.di_gen;
inode->i_size = ip->i_d.di_size; i_size_write(inode, ip->i_d.di_size);
inode->i_blocks = inode->i_blocks =
XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks); XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec; inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
......
...@@ -208,11 +208,11 @@ vn_revalidate( ...@@ -208,11 +208,11 @@ vn_revalidate(
inode->i_nlink = va.va_nlink; inode->i_nlink = va.va_nlink;
inode->i_uid = va.va_uid; inode->i_uid = va.va_uid;
inode->i_gid = va.va_gid; inode->i_gid = va.va_gid;
inode->i_size = va.va_size;
inode->i_blocks = va.va_nblocks; inode->i_blocks = va.va_nblocks;
inode->i_mtime = va.va_mtime; inode->i_mtime = va.va_mtime;
inode->i_ctime = va.va_ctime; inode->i_ctime = va.va_ctime;
inode->i_atime = va.va_atime; inode->i_atime = va.va_atime;
i_size_write(inode, va.va_size);
VUNMODIFY(vp); VUNMODIFY(vp);
} }
return -error; return -error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment