diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/aops.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmfs.c | 8 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 33 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.c | 7 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 38 |
5 files changed, 33 insertions, 64 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 8e7cafb5fc6c..0023b31e48a8 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
222 | goto out; | 222 | goto out; |
223 | } | 223 | } |
224 | 224 | ||
225 | down_read(&OCFS2_I(inode)->ip_alloc_sem); | 225 | if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) { |
226 | ret = AOP_TRUNCATED_PAGE; | ||
227 | goto out_meta_unlock; | ||
228 | } | ||
226 | 229 | ||
227 | /* | 230 | /* |
228 | * i_size might have just been updated as we grabed the meta lock. We | 231 | * i_size might have just been updated as we grabed the meta lock. We |
@@ -235,10 +238,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
235 | * XXX sys_readahead() seems to get that wrong? | 238 | * XXX sys_readahead() seems to get that wrong? |
236 | */ | 239 | */ |
237 | if (start >= i_size_read(inode)) { | 240 | if (start >= i_size_read(inode)) { |
238 | char *addr = kmap(page); | 241 | zero_user_page(page, 0, PAGE_SIZE, KM_USER0); |
239 | memset(addr, 0, PAGE_SIZE); | ||
240 | flush_dcache_page(page); | ||
241 | kunmap(page); | ||
242 | SetPageUptodate(page); | 242 | SetPageUptodate(page); |
243 | ret = 0; | 243 | ret = 0; |
244 | goto out_alloc; | 244 | goto out_alloc; |
@@ -258,6 +258,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
258 | ocfs2_data_unlock(inode, 0); | 258 | ocfs2_data_unlock(inode, 0); |
259 | out_alloc: | 259 | out_alloc: |
260 | up_read(&OCFS2_I(inode)->ip_alloc_sem); | 260 | up_read(&OCFS2_I(inode)->ip_alloc_sem); |
261 | out_meta_unlock: | ||
261 | ocfs2_meta_unlock(inode, 0); | 262 | ocfs2_meta_unlock(inode, 0); |
262 | out: | 263 | out: |
263 | if (unlock) | 264 | if (unlock) |
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c index 5671cf9d6383..fd8cb1badc9b 100644 --- a/fs/ocfs2/dlm/dlmfs.c +++ b/fs/ocfs2/dlm/dlmfs.c | |||
@@ -262,12 +262,10 @@ static void dlmfs_init_once(void *foo, | |||
262 | struct dlmfs_inode_private *ip = | 262 | struct dlmfs_inode_private *ip = |
263 | (struct dlmfs_inode_private *) foo; | 263 | (struct dlmfs_inode_private *) foo; |
264 | 264 | ||
265 | if (flags & SLAB_CTOR_CONSTRUCTOR) { | 265 | ip->ip_dlm = NULL; |
266 | ip->ip_dlm = NULL; | 266 | ip->ip_parent = NULL; |
267 | ip->ip_parent = NULL; | ||
268 | 267 | ||
269 | inode_init_once(&ip->ip_vfs_inode); | 268 | inode_init_once(&ip->ip_vfs_inode); |
270 | } | ||
271 | } | 269 | } |
272 | 270 | ||
273 | static struct inode *dlmfs_alloc_inode(struct super_block *sb) | 271 | static struct inode *dlmfs_alloc_inode(struct super_block *sb) |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9395b4fa547d..ac6c96431bbc 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -326,6 +326,7 @@ static int ocfs2_truncate_file(struct inode *inode, | |||
326 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 326 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
327 | (unsigned long long)new_i_size); | 327 | (unsigned long long)new_i_size); |
328 | 328 | ||
329 | unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1); | ||
329 | truncate_inode_pages(inode->i_mapping, new_i_size); | 330 | truncate_inode_pages(inode->i_mapping, new_i_size); |
330 | 331 | ||
331 | fe = (struct ocfs2_dinode *) di_bh->b_data; | 332 | fe = (struct ocfs2_dinode *) di_bh->b_data; |
@@ -1418,36 +1419,6 @@ out: | |||
1418 | return total ? total : ret; | 1419 | return total ? total : ret; |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | static int ocfs2_check_iovec(const struct iovec *iov, size_t *counted, | ||
1422 | unsigned long *nr_segs) | ||
1423 | { | ||
1424 | size_t ocount; /* original count */ | ||
1425 | unsigned long seg; | ||
1426 | |||
1427 | ocount = 0; | ||
1428 | for (seg = 0; seg < *nr_segs; seg++) { | ||
1429 | const struct iovec *iv = &iov[seg]; | ||
1430 | |||
1431 | /* | ||
1432 | * If any segment has a negative length, or the cumulative | ||
1433 | * length ever wraps negative then return -EINVAL. | ||
1434 | */ | ||
1435 | ocount += iv->iov_len; | ||
1436 | if (unlikely((ssize_t)(ocount|iv->iov_len) < 0)) | ||
1437 | return -EINVAL; | ||
1438 | if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len)) | ||
1439 | continue; | ||
1440 | if (seg == 0) | ||
1441 | return -EFAULT; | ||
1442 | *nr_segs = seg; | ||
1443 | ocount -= iv->iov_len; /* This segment is no good */ | ||
1444 | break; | ||
1445 | } | ||
1446 | |||
1447 | *counted = ocount; | ||
1448 | return 0; | ||
1449 | } | ||
1450 | |||
1451 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | 1422 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, |
1452 | const struct iovec *iov, | 1423 | const struct iovec *iov, |
1453 | unsigned long nr_segs, | 1424 | unsigned long nr_segs, |
@@ -1470,7 +1441,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1470 | if (iocb->ki_left == 0) | 1441 | if (iocb->ki_left == 0) |
1471 | return 0; | 1442 | return 0; |
1472 | 1443 | ||
1473 | ret = ocfs2_check_iovec(iov, &ocount, &nr_segs); | 1444 | ret = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ); |
1474 | if (ret) | 1445 | if (ret) |
1475 | return ret; | 1446 | return ret; |
1476 | 1447 | ||
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 4dedd9789108..545f7892cdf3 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -471,9 +471,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
471 | 471 | ||
472 | mutex_lock(&local_alloc_inode->i_mutex); | 472 | mutex_lock(&local_alloc_inode->i_mutex); |
473 | 473 | ||
474 | ac->ac_inode = local_alloc_inode; | ||
475 | ac->ac_which = OCFS2_AC_USE_LOCAL; | ||
476 | |||
477 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) { | 474 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) { |
478 | status = -ENOSPC; | 475 | status = -ENOSPC; |
479 | goto bail; | 476 | goto bail; |
@@ -511,10 +508,14 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
511 | } | 508 | } |
512 | } | 509 | } |
513 | 510 | ||
511 | ac->ac_inode = local_alloc_inode; | ||
512 | ac->ac_which = OCFS2_AC_USE_LOCAL; | ||
514 | get_bh(osb->local_alloc_bh); | 513 | get_bh(osb->local_alloc_bh); |
515 | ac->ac_bh = osb->local_alloc_bh; | 514 | ac->ac_bh = osb->local_alloc_bh; |
516 | status = 0; | 515 | status = 0; |
517 | bail: | 516 | bail: |
517 | if (status < 0 && local_alloc_inode) | ||
518 | iput(local_alloc_inode); | ||
518 | 519 | ||
519 | mlog_exit(status); | 520 | mlog_exit(status); |
520 | return status; | 521 | return status; |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 7c5e3f5d6634..86b559c7dce9 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -937,31 +937,29 @@ static void ocfs2_inode_init_once(void *data, | |||
937 | { | 937 | { |
938 | struct ocfs2_inode_info *oi = data; | 938 | struct ocfs2_inode_info *oi = data; |
939 | 939 | ||
940 | if (flags & SLAB_CTOR_CONSTRUCTOR) { | 940 | oi->ip_flags = 0; |
941 | oi->ip_flags = 0; | 941 | oi->ip_open_count = 0; |
942 | oi->ip_open_count = 0; | 942 | spin_lock_init(&oi->ip_lock); |
943 | spin_lock_init(&oi->ip_lock); | 943 | ocfs2_extent_map_init(&oi->vfs_inode); |
944 | ocfs2_extent_map_init(&oi->vfs_inode); | 944 | INIT_LIST_HEAD(&oi->ip_io_markers); |
945 | INIT_LIST_HEAD(&oi->ip_io_markers); | 945 | oi->ip_created_trans = 0; |
946 | oi->ip_created_trans = 0; | 946 | oi->ip_last_trans = 0; |
947 | oi->ip_last_trans = 0; | 947 | oi->ip_dir_start_lookup = 0; |
948 | oi->ip_dir_start_lookup = 0; | ||
949 | 948 | ||
950 | init_rwsem(&oi->ip_alloc_sem); | 949 | init_rwsem(&oi->ip_alloc_sem); |
951 | mutex_init(&oi->ip_io_mutex); | 950 | mutex_init(&oi->ip_io_mutex); |
952 | 951 | ||
953 | oi->ip_blkno = 0ULL; | 952 | oi->ip_blkno = 0ULL; |
954 | oi->ip_clusters = 0; | 953 | oi->ip_clusters = 0; |
955 | 954 | ||
956 | ocfs2_lock_res_init_once(&oi->ip_rw_lockres); | 955 | ocfs2_lock_res_init_once(&oi->ip_rw_lockres); |
957 | ocfs2_lock_res_init_once(&oi->ip_meta_lockres); | 956 | ocfs2_lock_res_init_once(&oi->ip_meta_lockres); |
958 | ocfs2_lock_res_init_once(&oi->ip_data_lockres); | 957 | ocfs2_lock_res_init_once(&oi->ip_data_lockres); |
959 | ocfs2_lock_res_init_once(&oi->ip_open_lockres); | 958 | ocfs2_lock_res_init_once(&oi->ip_open_lockres); |
960 | 959 | ||
961 | ocfs2_metadata_cache_init(&oi->vfs_inode); | 960 | ocfs2_metadata_cache_init(&oi->vfs_inode); |
962 | 961 | ||
963 | inode_init_once(&oi->vfs_inode); | 962 | inode_init_once(&oi->vfs_inode); |
964 | } | ||
965 | } | 963 | } |
966 | 964 | ||
967 | static int ocfs2_initialize_mem_caches(void) | 965 | static int ocfs2_initialize_mem_caches(void) |