Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2: (22 commits)
ocfs2: Fix possible deadlock when extending quota file
ocfs2: keep index within status_map[]
ocfs2: Initialize the cluster we're writing to in a non-sparse extend
ocfs2: Remove redundant BUG_ON in __dlm_queue_ast()
ocfs2/quota: Release lock for error in ocfs2_quota_write.
ocfs2: Define credit counts for quota operations
ocfs2: Remove syncjiff field from quota info
ocfs2: Fix initialization of blockcheck stats
ocfs2: Zero out padding of on disk dquot structure
ocfs2: Initialize blocks allocated to local quota file
ocfs2: Mark buffer uptodate before calling ocfs2_journal_access_dq()
ocfs2: Make global quota files blocksize aligned
ocfs2: Use ocfs2_rec_clusters in ocfs2_adjust_adjacent_records.
ocfs2: Fix deadlock on umount
ocfs2: Add extra credits and access the modified bh in update_edge_lengths.
ocfs2: Fail ocfs2_get_block() immediately when a block needs allocation
ocfs2: Fix error return in ocfs2_write_cluster()
ocfs2: Fix compilation warning for fs/ocfs2/xattr.c
ocfs2: Initialize count in aio_write before generic_write_checks
ocfs2: log the actual return value of ocfs2_file_aio_write()
...

+366 -144
+41 -6
fs/ocfs2/alloc.c
··· 1914 1914 * immediately to their right. 1915 1915 */ 1916 1916 left_clusters = le32_to_cpu(right_child_el->l_recs[0].e_cpos); 1917 - if (ocfs2_is_empty_extent(&right_child_el->l_recs[0])) { 1917 + if (!ocfs2_rec_clusters(right_child_el, &right_child_el->l_recs[0])) { 1918 + BUG_ON(right_child_el->l_tree_depth); 1918 1919 BUG_ON(le16_to_cpu(right_child_el->l_next_free_rec) <= 1); 1919 1920 left_clusters = le32_to_cpu(right_child_el->l_recs[1].e_cpos); 1920 1921 } ··· 2477 2476 return ret; 2478 2477 } 2479 2478 2480 - static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle, 2481 - struct ocfs2_path *path) 2479 + static int ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle, 2480 + int subtree_index, struct ocfs2_path *path) 2482 2481 { 2483 - int i, idx; 2482 + int i, idx, ret; 2484 2483 struct ocfs2_extent_rec *rec; 2485 2484 struct ocfs2_extent_list *el; 2486 2485 struct ocfs2_extent_block *eb; 2487 2486 u32 range; 2487 + 2488 + /* 2489 + * In normal tree rotation process, we will never touch the 2490 + * tree branch above subtree_index and ocfs2_extend_rotate_transaction 2491 + * doesn't reserve the credits for them either. 2492 + * 2493 + * But we do have a special case here which will update the rightmost 2494 + * records for all the bh in the path. 2495 + * So we have to allocate extra credits and access them. 2496 + */ 2497 + ret = ocfs2_extend_trans(handle, 2498 + handle->h_buffer_credits + subtree_index); 2499 + if (ret) { 2500 + mlog_errno(ret); 2501 + goto out; 2502 + } 2503 + 2504 + ret = ocfs2_journal_access_path(inode, handle, path); 2505 + if (ret) { 2506 + mlog_errno(ret); 2507 + goto out; 2508 + } 2488 2509 2489 2510 /* Path should always be rightmost. */ 2490 2511 eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data; ··· 2528 2505 2529 2506 ocfs2_journal_dirty(handle, path->p_node[i].bh); 2530 2507 } 2508 + out: 2509 + return ret; 2531 2510 } 2532 2511 2533 2512 static void ocfs2_unlink_path(struct inode *inode, handle_t *handle, ··· 2742 2717 if (del_right_subtree) { 2743 2718 ocfs2_unlink_subtree(inode, handle, left_path, right_path, 2744 2719 subtree_index, dealloc); 2745 - ocfs2_update_edge_lengths(inode, handle, left_path); 2720 + ret = ocfs2_update_edge_lengths(inode, handle, subtree_index, 2721 + left_path); 2722 + if (ret) { 2723 + mlog_errno(ret); 2724 + goto out; 2725 + } 2746 2726 2747 2727 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; 2748 2728 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); ··· 3064 3034 3065 3035 ocfs2_unlink_subtree(inode, handle, left_path, path, 3066 3036 subtree_index, dealloc); 3067 - ocfs2_update_edge_lengths(inode, handle, left_path); 3037 + ret = ocfs2_update_edge_lengths(inode, handle, subtree_index, 3038 + left_path); 3039 + if (ret) { 3040 + mlog_errno(ret); 3041 + goto out; 3042 + } 3068 3043 3069 3044 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; 3070 3045 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
+49 -20
fs/ocfs2/aops.c
··· 193 193 (unsigned long long)OCFS2_I(inode)->ip_blkno); 194 194 mlog(ML_ERROR, "Size %llu, clusters %u\n", (unsigned long long)i_size_read(inode), OCFS2_I(inode)->ip_clusters); 195 195 dump_stack(); 196 + goto bail; 196 197 } 197 198 198 199 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); ··· 895 894 */ 896 895 unsigned c_new; 897 896 unsigned c_unwritten; 897 + unsigned c_needs_zero; 898 898 }; 899 - 900 - static inline int ocfs2_should_zero_cluster(struct ocfs2_write_cluster_desc *d) 901 - { 902 - return d->c_new || d->c_unwritten; 903 - } 904 899 905 900 struct ocfs2_write_ctxt { 906 901 /* Logical cluster position / len of write */ 907 902 u32 w_cpos; 908 903 u32 w_clen; 904 + 905 + /* First cluster allocated in a nonsparse extend */ 906 + u32 w_first_new_cpos; 909 907 910 908 struct ocfs2_write_cluster_desc w_desc[OCFS2_MAX_CLUSTERS_PER_PAGE]; 911 909 ··· 983 983 return -ENOMEM; 984 984 985 985 wc->w_cpos = pos >> osb->s_clustersize_bits; 986 + wc->w_first_new_cpos = UINT_MAX; 986 987 cend = (pos + len - 1) >> osb->s_clustersize_bits; 987 988 wc->w_clen = cend - wc->w_cpos + 1; 988 989 get_bh(di_bh); ··· 1218 1217 */ 1219 1218 static int ocfs2_write_cluster(struct address_space *mapping, 1220 1219 u32 phys, unsigned int unwritten, 1220 + unsigned int should_zero, 1221 1221 struct ocfs2_alloc_context *data_ac, 1222 1222 struct ocfs2_alloc_context *meta_ac, 1223 1223 struct ocfs2_write_ctxt *wc, u32 cpos, 1224 1224 loff_t user_pos, unsigned user_len) 1225 1225 { 1226 - int ret, i, new, should_zero = 0; 1226 + int ret, i, new; 1227 1227 u64 v_blkno, p_blkno; 1228 1228 struct inode *inode = mapping->host; 1229 1229 struct ocfs2_extent_tree et; 1230 1230 1231 1231 new = phys == 0 ? 1 : 0; 1232 - if (new || unwritten) 1233 - should_zero = 1; 1234 - 1235 1232 if (new) { 1236 1233 u32 tmp_pos; 1237 1234 ··· 1300 1301 if (tmpret) { 1301 1302 mlog_errno(tmpret); 1302 1303 if (ret == 0) 1303 - tmpret = ret; 1304 + ret = tmpret; 1304 1305 } 1305 1306 } 1306 1307 ··· 1340 1341 local_len = osb->s_clustersize - cluster_off; 1341 1342 1342 1343 ret = ocfs2_write_cluster(mapping, desc->c_phys, 1343 - desc->c_unwritten, data_ac, meta_ac, 1344 + desc->c_unwritten, 1345 + desc->c_needs_zero, 1346 + data_ac, meta_ac, 1344 1347 wc, desc->c_cpos, pos, local_len); 1345 1348 if (ret) { 1346 1349 mlog_errno(ret); ··· 1392 1391 * newly allocated cluster. 1393 1392 */ 1394 1393 desc = &wc->w_desc[0]; 1395 - if (ocfs2_should_zero_cluster(desc)) 1394 + if (desc->c_needs_zero) 1396 1395 ocfs2_figure_cluster_boundaries(osb, 1397 1396 desc->c_cpos, 1398 1397 &wc->w_target_from, 1399 1398 NULL); 1400 1399 1401 1400 desc = &wc->w_desc[wc->w_clen - 1]; 1402 - if (ocfs2_should_zero_cluster(desc)) 1401 + if (desc->c_needs_zero) 1403 1402 ocfs2_figure_cluster_boundaries(osb, 1404 1403 desc->c_cpos, 1405 1404 NULL, ··· 1467 1466 phys++; 1468 1467 } 1469 1468 1469 + /* 1470 + * If w_first_new_cpos is < UINT_MAX, we have a non-sparse 1471 + * file that got extended. w_first_new_cpos tells us 1472 + * where the newly allocated clusters are so we can 1473 + * zero them. 1474 + */ 1475 + if (desc->c_cpos >= wc->w_first_new_cpos) { 1476 + BUG_ON(phys == 0); 1477 + desc->c_needs_zero = 1; 1478 + } 1479 + 1470 1480 desc->c_phys = phys; 1471 1481 if (phys == 0) { 1472 1482 desc->c_new = 1; 1483 + desc->c_needs_zero = 1; 1473 1484 *clusters_to_alloc = *clusters_to_alloc + 1; 1474 1485 } 1475 - if (ext_flags & OCFS2_EXT_UNWRITTEN) 1486 + 1487 + if (ext_flags & OCFS2_EXT_UNWRITTEN) { 1476 1488 desc->c_unwritten = 1; 1489 + desc->c_needs_zero = 1; 1490 + } 1477 1491 1478 1492 num_clusters--; 1479 1493 } ··· 1648 1632 if (newsize <= i_size_read(inode)) 1649 1633 return 0; 1650 1634 1651 - ret = ocfs2_extend_no_holes(inode, newsize, newsize - len); 1635 + ret = ocfs2_extend_no_holes(inode, newsize, pos); 1652 1636 if (ret) 1653 1637 mlog_errno(ret); 1638 + 1639 + wc->w_first_new_cpos = 1640 + ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode)); 1654 1641 1655 1642 return ret; 1656 1643 } ··· 1663 1644 struct page **pagep, void **fsdata, 1664 1645 struct buffer_head *di_bh, struct page *mmap_page) 1665 1646 { 1666 - int ret, credits = OCFS2_INODE_UPDATE_CREDITS; 1647 + int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS; 1667 1648 unsigned int clusters_to_alloc, extents_to_split; 1668 1649 struct ocfs2_write_ctxt *wc; 1669 1650 struct inode *inode = mapping->host; ··· 1741 1722 1742 1723 } 1743 1724 1744 - ocfs2_set_target_boundaries(osb, wc, pos, len, 1745 - clusters_to_alloc + extents_to_split); 1725 + /* 1726 + * We have to zero sparse allocated clusters, unwritten extent clusters, 1727 + * and non-sparse clusters we just extended. For non-sparse writes, 1728 + * we know zeros will only be needed in the first and/or last cluster. 1729 + */ 1730 + if (clusters_to_alloc || extents_to_split || 1731 + wc->w_desc[0].c_needs_zero || 1732 + wc->w_desc[wc->w_clen - 1].c_needs_zero) 1733 + cluster_of_pages = 1; 1734 + else 1735 + cluster_of_pages = 0; 1736 + 1737 + ocfs2_set_target_boundaries(osb, wc, pos, len, cluster_of_pages); 1746 1738 1747 1739 handle = ocfs2_start_trans(osb, credits); 1748 1740 if (IS_ERR(handle)) { ··· 1786 1756 * extent. 1787 1757 */ 1788 1758 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, 1789 - clusters_to_alloc + extents_to_split, 1790 - mmap_page); 1759 + cluster_of_pages, mmap_page); 1791 1760 if (ret) { 1792 1761 mlog_errno(ret); 1793 1762 goto out_quota;
+27 -8
fs/ocfs2/dcache.c
··· 310 310 return ret; 311 311 } 312 312 313 - static DEFINE_SPINLOCK(dentry_list_lock); 313 + DEFINE_SPINLOCK(dentry_list_lock); 314 314 315 315 /* We limit the number of dentry locks to drop in one go. We have 316 316 * this limit so that we don't starve other users of ocfs2_wq. */ 317 317 #define DL_INODE_DROP_COUNT 64 318 318 319 319 /* Drop inode references from dentry locks */ 320 - void ocfs2_drop_dl_inodes(struct work_struct *work) 320 + static void __ocfs2_drop_dl_inodes(struct ocfs2_super *osb, int drop_count) 321 321 { 322 - struct ocfs2_super *osb = container_of(work, struct ocfs2_super, 323 - dentry_lock_work); 324 322 struct ocfs2_dentry_lock *dl; 325 - int drop_count = DL_INODE_DROP_COUNT; 326 323 327 324 spin_lock(&dentry_list_lock); 328 - while (osb->dentry_lock_list && drop_count--) { 325 + while (osb->dentry_lock_list && (drop_count < 0 || drop_count--)) { 329 326 dl = osb->dentry_lock_list; 330 327 osb->dentry_lock_list = dl->dl_next; 331 328 spin_unlock(&dentry_list_lock); ··· 330 333 kfree(dl); 331 334 spin_lock(&dentry_list_lock); 332 335 } 333 - if (osb->dentry_lock_list) 336 + spin_unlock(&dentry_list_lock); 337 + } 338 + 339 + void ocfs2_drop_dl_inodes(struct work_struct *work) 340 + { 341 + struct ocfs2_super *osb = container_of(work, struct ocfs2_super, 342 + dentry_lock_work); 343 + 344 + __ocfs2_drop_dl_inodes(osb, DL_INODE_DROP_COUNT); 345 + /* 346 + * Don't queue dropping if umount is in progress. We flush the 347 + * list in ocfs2_dismount_volume 348 + */ 349 + spin_lock(&dentry_list_lock); 350 + if (osb->dentry_lock_list && 351 + !ocfs2_test_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED)) 334 352 queue_work(ocfs2_wq, &osb->dentry_lock_work); 335 353 spin_unlock(&dentry_list_lock); 354 + } 355 + 356 + /* Flush the whole work queue */ 357 + void ocfs2_drop_all_dl_inodes(struct ocfs2_super *osb) 358 + { 359 + __ocfs2_drop_dl_inodes(osb, -1); 336 360 } 337 361 338 362 /* ··· 386 368 /* We leave dropping of inode reference to ocfs2_wq as that can 387 369 * possibly lead to inode deletion which gets tricky */ 388 370 spin_lock(&dentry_list_lock); 389 - if (!osb->dentry_lock_list) 371 + if (!osb->dentry_lock_list && 372 + !ocfs2_test_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED)) 390 373 queue_work(ocfs2_wq, &osb->dentry_lock_work); 391 374 dl->dl_next = osb->dentry_lock_list; 392 375 osb->dentry_lock_list = dl;
+3
fs/ocfs2/dcache.h
··· 49 49 int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode, 50 50 u64 parent_blkno); 51 51 52 + extern spinlock_t dentry_list_lock; 53 + 52 54 void ocfs2_dentry_lock_put(struct ocfs2_super *osb, 53 55 struct ocfs2_dentry_lock *dl); 54 56 55 57 void ocfs2_drop_dl_inodes(struct work_struct *work); 58 + void ocfs2_drop_all_dl_inodes(struct ocfs2_super *osb); 56 59 57 60 struct dentry *ocfs2_find_local_alias(struct inode *inode, u64 parent_blkno, 58 61 int skip_unhashed);
-1
fs/ocfs2/dlm/dlmast.c
··· 103 103 lock->ast_pending, lock->ml.type); 104 104 BUG(); 105 105 } 106 - BUG_ON(!list_empty(&lock->ast_list)); 107 106 if (lock->ast_pending) 108 107 mlog(0, "lock has an ast getting flushed right now\n"); 109 108
+1 -1
fs/ocfs2/dlm/dlmrecovery.c
··· 1118 1118 1119 1119 mlog(0, "%s:%.*s: sending mig lockres (%s) to %u\n", 1120 1120 dlm->name, res->lockname.len, res->lockname.name, 1121 - orig_flags & DLM_MRES_MIGRATION ? "migrate" : "recovery", 1121 + orig_flags & DLM_MRES_MIGRATION ? "migration" : "recovery", 1122 1122 send_to); 1123 1123 1124 1124 /* send it */
+4 -1
fs/ocfs2/file.c
··· 1851 1851 if (ret) 1852 1852 goto out_dio; 1853 1853 1854 + count = ocount; 1854 1855 ret = generic_write_checks(file, ppos, &count, 1855 1856 S_ISBLK(inode->i_mode)); 1856 1857 if (ret) ··· 1919 1918 1920 1919 mutex_unlock(&inode->i_mutex); 1921 1920 1921 + if (written) 1922 + ret = written; 1922 1923 mlog_exit(ret); 1923 - return written ? written : ret; 1924 + return ret; 1924 1925 } 1925 1926 1926 1927 static int ocfs2_splice_to_file(struct pipe_inode_info *pipe,
+7 -1
fs/ocfs2/journal.c
··· 1954 1954 os->os_osb = osb; 1955 1955 os->os_count = 0; 1956 1956 os->os_seqno = 0; 1957 - os->os_scantime = CURRENT_TIME; 1958 1957 mutex_init(&os->os_lock); 1959 1958 INIT_DELAYED_WORK(&os->os_orphan_scan_work, ocfs2_orphan_scan_work); 1959 + } 1960 1960 1961 + void ocfs2_orphan_scan_start(struct ocfs2_super *osb) 1962 + { 1963 + struct ocfs2_orphan_scan *os; 1964 + 1965 + os = &osb->osb_orphan_scan; 1966 + os->os_scantime = CURRENT_TIME; 1961 1967 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb)) 1962 1968 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE); 1963 1969 else {
+12 -9
fs/ocfs2/journal.h
··· 145 145 146 146 /* Exported only for the journal struct init code in super.c. Do not call. */ 147 147 void ocfs2_orphan_scan_init(struct ocfs2_super *osb); 148 + void ocfs2_orphan_scan_start(struct ocfs2_super *osb); 148 149 void ocfs2_orphan_scan_stop(struct ocfs2_super *osb); 149 150 void ocfs2_orphan_scan_exit(struct ocfs2_super *osb); 150 151 ··· 330 329 /* extended attribute block update */ 331 330 #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 332 331 333 - /* global quotafile inode update, data block */ 334 - #define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) 332 + /* Update of a single quota block */ 333 + #define OCFS2_QUOTA_BLOCK_UPDATE_CREDITS 1 335 334 335 + /* global quotafile inode update, data block */ 336 + #define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + \ 337 + OCFS2_QUOTA_BLOCK_UPDATE_CREDITS) 338 + 339 + #define OCFS2_LOCAL_QINFO_WRITE_CREDITS OCFS2_QUOTA_BLOCK_UPDATE_CREDITS 336 340 /* 337 341 * The two writes below can accidentally see global info dirty due 338 342 * to set_info() quotactl so make them prepared for the writes. 339 343 */ 340 344 /* quota data block, global info */ 341 345 /* Write to local quota file */ 342 - #define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + 1) 346 + #define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \ 347 + OCFS2_QUOTA_BLOCK_UPDATE_CREDITS) 343 348 344 349 /* global quota data block, local quota data block, global quota inode, 345 350 * global quota info */ 346 - #define OCFS2_QSYNC_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 3) 351 + #define OCFS2_QSYNC_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \ 352 + 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS) 347 353 348 354 static inline int ocfs2_quota_trans_credits(struct super_block *sb) 349 355 { ··· 362 354 credits += OCFS2_QWRITE_CREDITS; 363 355 return credits; 364 356 } 365 - 366 - /* Number of credits needed for removing quota structure from file */ 367 - int ocfs2_calc_qdel_credits(struct super_block *sb, int type); 368 - /* Number of credits needed for initialization of new quota structure */ 369 - int ocfs2_calc_qinit_credits(struct super_block *sb, int type); 370 357 371 358 /* group extend. inode update and last group update. */ 372 359 #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
+18 -4
fs/ocfs2/ocfs2.h
··· 224 224 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */ 225 225 }; 226 226 227 - #define OCFS2_OSB_SOFT_RO 0x0001 228 - #define OCFS2_OSB_HARD_RO 0x0002 229 - #define OCFS2_OSB_ERROR_FS 0x0004 230 - #define OCFS2_DEFAULT_ATIME_QUANTUM 60 227 + #define OCFS2_OSB_SOFT_RO 0x0001 228 + #define OCFS2_OSB_HARD_RO 0x0002 229 + #define OCFS2_OSB_ERROR_FS 0x0004 230 + #define OCFS2_OSB_DROP_DENTRY_LOCK_IMMED 0x0008 231 + 232 + #define OCFS2_DEFAULT_ATIME_QUANTUM 60 231 233 232 234 struct ocfs2_journal; 233 235 struct ocfs2_slot_info; ··· 490 488 spin_lock(&osb->osb_lock); 491 489 osb->osb_flags |= flag; 492 490 spin_unlock(&osb->osb_lock); 491 + } 492 + 493 + 494 + static inline unsigned long ocfs2_test_osb_flag(struct ocfs2_super *osb, 495 + unsigned long flag) 496 + { 497 + unsigned long ret; 498 + 499 + spin_lock(&osb->osb_lock); 500 + ret = osb->osb_flags & flag; 501 + spin_unlock(&osb->osb_lock); 502 + return ret; 493 503 } 494 504 495 505 static inline void ocfs2_set_ro_flag(struct ocfs2_super *osb,
-1
fs/ocfs2/quota.h
··· 50 50 unsigned int dqi_chunks; /* Number of chunks in local quota file */ 51 51 unsigned int dqi_blocks; /* Number of blocks allocated for local quota file */ 52 52 unsigned int dqi_syncms; /* How often should we sync with other nodes */ 53 - unsigned int dqi_syncjiff; /* Precomputed dqi_syncms in jiffies */ 54 53 struct list_head dqi_chunk; /* List of chunks */ 55 54 struct inode *dqi_gqinode; /* Global quota file inode */ 56 55 struct ocfs2_lock_res dqi_gqlock; /* Lock protecting quota information structure */
+72 -62
fs/ocfs2/quota_global.c
··· 69 69 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 70 70 d->dqb_btime = cpu_to_le64(m->dqb_btime); 71 71 d->dqb_itime = cpu_to_le64(m->dqb_itime); 72 + d->dqb_pad1 = d->dqb_pad2 = 0; 72 73 } 73 74 74 75 static int ocfs2_global_is_id(void *dp, struct dquot *dquot) ··· 212 211 213 212 mutex_lock_nested(&gqinode->i_mutex, I_MUTEX_QUOTA); 214 213 if (gqinode->i_size < off + len) { 215 - down_write(&OCFS2_I(gqinode)->ip_alloc_sem); 216 - err = ocfs2_extend_no_holes(gqinode, off + len, off); 217 - up_write(&OCFS2_I(gqinode)->ip_alloc_sem); 218 - if (err < 0) 219 - goto out; 214 + loff_t rounded_end = 215 + ocfs2_align_bytes_to_blocks(sb, off + len); 216 + 217 + /* Space is already allocated in ocfs2_global_read_dquot() */ 220 218 err = ocfs2_simple_size_update(gqinode, 221 219 oinfo->dqi_gqi_bh, 222 - off + len); 220 + rounded_end); 223 221 if (err < 0) 224 222 goto out; 225 223 new = 1; ··· 234 234 } 235 235 if (err) { 236 236 mlog_errno(err); 237 - return err; 237 + goto out; 238 238 } 239 239 lock_buffer(bh); 240 240 if (new) ··· 342 342 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); 343 343 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); 344 344 oinfo->dqi_syncms = le32_to_cpu(dinfo.dqi_syncms); 345 - oinfo->dqi_syncjiff = msecs_to_jiffies(oinfo->dqi_syncms); 346 345 oinfo->dqi_gi.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); 347 346 oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); 348 347 oinfo->dqi_gi.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); ··· 351 352 oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi); 352 353 INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn); 353 354 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work, 354 - oinfo->dqi_syncjiff); 355 + msecs_to_jiffies(oinfo->dqi_syncms)); 355 356 356 357 out_err: 357 358 mlog_exit(status); ··· 401 402 return err; 402 403 } 403 404 405 + static int ocfs2_global_qinit_alloc(struct super_block *sb, int type) 406 + { 407 + struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv; 408 + 409 + /* 410 + * We may need to allocate tree blocks and a leaf block but not the 411 + * root block 412 + */ 413 + return oinfo->dqi_gi.dqi_qtree_depth; 414 + } 415 + 416 + static int ocfs2_calc_global_qinit_credits(struct super_block *sb, int type) 417 + { 418 + /* We modify all the allocated blocks, tree root, and info block */ 419 + return (ocfs2_global_qinit_alloc(sb, type) + 2) * 420 + OCFS2_QUOTA_BLOCK_UPDATE_CREDITS; 421 + } 422 + 404 423 /* Read in information from global quota file and acquire a reference to it. 405 424 * dquot_acquire() has already started the transaction and locked quota file */ 406 425 int ocfs2_global_read_dquot(struct dquot *dquot) 407 426 { 408 427 int err, err2, ex = 0; 409 - struct ocfs2_mem_dqinfo *info = 410 - sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 428 + struct super_block *sb = dquot->dq_sb; 429 + int type = dquot->dq_type; 430 + struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv; 431 + struct ocfs2_super *osb = OCFS2_SB(sb); 432 + struct inode *gqinode = info->dqi_gqinode; 433 + int need_alloc = ocfs2_global_qinit_alloc(sb, type); 434 + handle_t *handle = NULL; 411 435 412 436 err = ocfs2_qinfo_lock(info, 0); 413 437 if (err < 0) ··· 441 419 OCFS2_DQUOT(dquot)->dq_use_count++; 442 420 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace; 443 421 OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes; 422 + ocfs2_qinfo_unlock(info, 0); 423 + 444 424 if (!dquot->dq_off) { /* No real quota entry? */ 445 - /* Upgrade to exclusive lock for allocation */ 446 - ocfs2_qinfo_unlock(info, 0); 447 - err = ocfs2_qinfo_lock(info, 1); 448 - if (err < 0) 449 - goto out_qlock; 450 425 ex = 1; 426 + /* 427 + * Add blocks to quota file before we start a transaction since 428 + * locking allocators ranks above a transaction start 429 + */ 430 + WARN_ON(journal_current_handle()); 431 + down_write(&OCFS2_I(gqinode)->ip_alloc_sem); 432 + err = ocfs2_extend_no_holes(gqinode, 433 + gqinode->i_size + (need_alloc << sb->s_blocksize_bits), 434 + gqinode->i_size); 435 + up_write(&OCFS2_I(gqinode)->ip_alloc_sem); 436 + if (err < 0) 437 + goto out; 451 438 } 439 + 440 + handle = ocfs2_start_trans(osb, 441 + ocfs2_calc_global_qinit_credits(sb, type)); 442 + if (IS_ERR(handle)) { 443 + err = PTR_ERR(handle); 444 + goto out; 445 + } 446 + err = ocfs2_qinfo_lock(info, ex); 447 + if (err < 0) 448 + goto out_trans; 452 449 err = qtree_write_dquot(&info->dqi_gi, dquot); 453 450 if (ex && info_dirty(sb_dqinfo(dquot->dq_sb, dquot->dq_type))) { 454 451 err2 = __ocfs2_global_write_info(dquot->dq_sb, dquot->dq_type); ··· 479 438 ocfs2_qinfo_unlock(info, 1); 480 439 else 481 440 ocfs2_qinfo_unlock(info, 0); 441 + out_trans: 442 + if (handle) 443 + ocfs2_commit_trans(osb, handle); 482 444 out: 483 445 if (err < 0) 484 446 mlog_errno(err); ··· 651 607 652 608 dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type); 653 609 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work, 654 - oinfo->dqi_syncjiff); 610 + msecs_to_jiffies(oinfo->dqi_syncms)); 655 611 } 656 612 657 613 /* ··· 679 635 return status; 680 636 } 681 637 682 - int ocfs2_calc_qdel_credits(struct super_block *sb, int type) 638 + static int ocfs2_calc_qdel_credits(struct super_block *sb, int type) 683 639 { 684 - struct ocfs2_mem_dqinfo *oinfo; 685 - int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, 686 - OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; 687 - 688 - if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type])) 689 - return 0; 690 - 691 - oinfo = sb_dqinfo(sb, type)->dqi_priv; 692 - /* We modify tree, leaf block, global info, local chunk header, 693 - * global and local inode */ 694 - return oinfo->dqi_gi.dqi_qtree_depth + 2 + 1 + 695 - 2 * OCFS2_INODE_UPDATE_CREDITS; 640 + struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv; 641 + /* 642 + * We modify tree, leaf block, global info, local chunk header, 643 + * global and local inode; OCFS2_QINFO_WRITE_CREDITS already 644 + * accounts for inode update 645 + */ 646 + return (oinfo->dqi_gi.dqi_qtree_depth + 2) * 647 + OCFS2_QUOTA_BLOCK_UPDATE_CREDITS + 648 + OCFS2_QINFO_WRITE_CREDITS + 649 + OCFS2_INODE_UPDATE_CREDITS; 696 650 } 697 651 698 652 static int ocfs2_release_dquot(struct dquot *dquot) ··· 722 680 return status; 723 681 } 724 682 725 - int ocfs2_calc_qinit_credits(struct super_block *sb, int type) 726 - { 727 - struct ocfs2_mem_dqinfo *oinfo; 728 - int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, 729 - OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; 730 - struct ocfs2_dinode *lfe, *gfe; 731 - 732 - if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type])) 733 - return 0; 734 - 735 - oinfo = sb_dqinfo(sb, type)->dqi_priv; 736 - gfe = (struct ocfs2_dinode *)oinfo->dqi_gqi_bh->b_data; 737 - lfe = (struct ocfs2_dinode *)oinfo->dqi_lqi_bh->b_data; 738 - /* We can extend local file + global file. In local file we 739 - * can modify info, chunk header block and dquot block. In 740 - * global file we can modify info, tree and leaf block */ 741 - return ocfs2_calc_extend_credits(sb, &lfe->id2.i_list, 0) + 742 - ocfs2_calc_extend_credits(sb, &gfe->id2.i_list, 0) + 743 - 3 + oinfo->dqi_gi.dqi_qtree_depth + 2; 744 - } 745 - 746 683 static int ocfs2_acquire_dquot(struct dquot *dquot) 747 684 { 748 - handle_t *handle; 749 685 struct ocfs2_mem_dqinfo *oinfo = 750 686 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 751 - struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); 752 687 int status = 0; 753 688 754 689 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type); ··· 734 715 status = ocfs2_lock_global_qf(oinfo, 1); 735 716 if (status < 0) 736 717 goto out; 737 - handle = ocfs2_start_trans(osb, 738 - ocfs2_calc_qinit_credits(dquot->dq_sb, dquot->dq_type)); 739 - if (IS_ERR(handle)) { 740 - status = PTR_ERR(handle); 741 - mlog_errno(status); 742 - goto out_ilock; 743 - } 744 718 status = dquot_acquire(dquot); 745 - ocfs2_commit_trans(osb, handle); 746 - out_ilock: 747 719 ocfs2_unlock_global_qf(oinfo, 1); 748 720 out: 749 721 mlog_exit(status);
+102 -24
fs/ocfs2/quota_local.c
··· 20 20 #include "sysfile.h" 21 21 #include "dlmglue.h" 22 22 #include "quota.h" 23 + #include "uptodate.h" 23 24 24 25 /* Number of local quota structures per block */ 25 26 static inline unsigned int ol_quota_entries_per_block(struct super_block *sb) ··· 101 100 handle_t *handle; 102 101 int status; 103 102 104 - handle = ocfs2_start_trans(OCFS2_SB(sb), 1); 103 + handle = ocfs2_start_trans(OCFS2_SB(sb), 104 + OCFS2_QUOTA_BLOCK_UPDATE_CREDITS); 105 105 if (IS_ERR(handle)) { 106 106 status = PTR_ERR(handle); 107 107 mlog_errno(status); ··· 612 610 goto out_bh; 613 611 /* Mark quota file as clean if we are recovering quota file of 614 612 * some other node. */ 615 - handle = ocfs2_start_trans(osb, 1); 613 + handle = ocfs2_start_trans(osb, 614 + OCFS2_LOCAL_QINFO_WRITE_CREDITS); 616 615 if (IS_ERR(handle)) { 617 616 status = PTR_ERR(handle); 618 617 mlog_errno(status); ··· 943 940 struct ocfs2_local_disk_chunk *dchunk; 944 941 int status; 945 942 handle_t *handle; 946 - struct buffer_head *bh = NULL; 943 + struct buffer_head *bh = NULL, *dbh = NULL; 947 944 u64 p_blkno; 948 945 949 946 /* We are protected by dqio_sem so no locking needed */ ··· 967 964 mlog_errno(status); 968 965 goto out; 969 966 } 970 - 971 - down_read(&OCFS2_I(lqinode)->ip_alloc_sem); 972 - status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks, 973 - &p_blkno, NULL, NULL); 974 - up_read(&OCFS2_I(lqinode)->ip_alloc_sem); 975 - if (status < 0) { 976 - mlog_errno(status); 977 - goto out; 978 - } 979 - bh = sb_getblk(sb, p_blkno); 980 - if (!bh) { 981 - status = -ENOMEM; 982 - mlog_errno(status); 983 - goto out; 984 - } 985 - dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data; 986 - 987 - handle = ocfs2_start_trans(OCFS2_SB(sb), 2); 967 + /* Local quota info and two new blocks we initialize */ 968 + handle = ocfs2_start_trans(OCFS2_SB(sb), 969 + OCFS2_LOCAL_QINFO_WRITE_CREDITS + 970 + 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS); 988 971 if (IS_ERR(handle)) { 989 972 status = PTR_ERR(handle); 990 973 mlog_errno(status); 991 974 goto out; 992 975 } 993 976 977 + /* Initialize chunk header */ 978 + down_read(&OCFS2_I(lqinode)->ip_alloc_sem); 979 + status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks, 980 + &p_blkno, NULL, NULL); 981 + up_read(&OCFS2_I(lqinode)->ip_alloc_sem); 982 + if (status < 0) { 983 + mlog_errno(status); 984 + goto out_trans; 985 + } 986 + bh = sb_getblk(sb, p_blkno); 987 + if (!bh) { 988 + status = -ENOMEM; 989 + mlog_errno(status); 990 + goto out_trans; 991 + } 992 + dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data; 993 + ocfs2_set_new_buffer_uptodate(lqinode, bh); 994 994 status = ocfs2_journal_access_dq(handle, lqinode, bh, 995 - OCFS2_JOURNAL_ACCESS_WRITE); 995 + OCFS2_JOURNAL_ACCESS_CREATE); 996 996 if (status < 0) { 997 997 mlog_errno(status); 998 998 goto out_trans; ··· 1005 999 memset(dchunk->dqc_bitmap, 0, 1006 1000 sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) - 1007 1001 OCFS2_QBLK_RESERVED_SPACE); 1008 - set_buffer_uptodate(bh); 1009 1002 unlock_buffer(bh); 1010 1003 status = ocfs2_journal_dirty(handle, bh); 1011 1004 if (status < 0) { ··· 1012 1007 goto out_trans; 1013 1008 } 1014 1009 1010 + /* Initialize new block with structures */ 1011 + down_read(&OCFS2_I(lqinode)->ip_alloc_sem); 1012 + status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks + 1, 1013 + &p_blkno, NULL, NULL); 1014 + up_read(&OCFS2_I(lqinode)->ip_alloc_sem); 1015 + if (status < 0) { 1016 + mlog_errno(status); 1017 + goto out_trans; 1018 + } 1019 + dbh = sb_getblk(sb, p_blkno); 1020 + if (!dbh) { 1021 + status = -ENOMEM; 1022 + mlog_errno(status); 1023 + goto out_trans; 1024 + } 1025 + ocfs2_set_new_buffer_uptodate(lqinode, dbh); 1026 + status = ocfs2_journal_access_dq(handle, lqinode, dbh, 1027 + OCFS2_JOURNAL_ACCESS_CREATE); 1028 + if (status < 0) { 1029 + mlog_errno(status); 1030 + goto out_trans; 1031 + } 1032 + lock_buffer(dbh); 1033 + memset(dbh->b_data, 0, sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE); 1034 + unlock_buffer(dbh); 1035 + status = ocfs2_journal_dirty(handle, dbh); 1036 + if (status < 0) { 1037 + mlog_errno(status); 1038 + goto out_trans; 1039 + } 1040 + 1041 + /* Update local quotafile info */ 1015 1042 oinfo->dqi_blocks += 2; 1016 1043 oinfo->dqi_chunks++; 1017 1044 status = ocfs2_local_write_info(sb, type); ··· 1068 1031 ocfs2_commit_trans(OCFS2_SB(sb), handle); 1069 1032 out: 1070 1033 brelse(bh); 1034 + brelse(dbh); 1071 1035 kmem_cache_free(ocfs2_qf_chunk_cachep, chunk); 1072 1036 return ERR_PTR(status); 1073 1037 } ··· 1086 1048 struct ocfs2_local_disk_chunk *dchunk; 1087 1049 int epb = ol_quota_entries_per_block(sb); 1088 1050 unsigned int chunk_blocks; 1051 + struct buffer_head *bh; 1052 + u64 p_blkno; 1089 1053 int status; 1090 1054 handle_t *handle; 1091 1055 ··· 1115 1075 mlog_errno(status); 1116 1076 goto out; 1117 1077 } 1118 - handle = ocfs2_start_trans(OCFS2_SB(sb), 2); 1078 + 1079 + /* Get buffer from the just added block */ 1080 + down_read(&OCFS2_I(lqinode)->ip_alloc_sem); 1081 + status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks, 1082 + &p_blkno, NULL, NULL); 1083 + up_read(&OCFS2_I(lqinode)->ip_alloc_sem); 1084 + if (status < 0) { 1085 + mlog_errno(status); 1086 + goto out; 1087 + } 1088 + bh = sb_getblk(sb, p_blkno); 1089 + if (!bh) { 1090 + status = -ENOMEM; 1091 + mlog_errno(status); 1092 + goto out; 1093 + } 1094 + ocfs2_set_new_buffer_uptodate(lqinode, bh); 1095 + 1096 + /* Local quota info, chunk header and the new block we initialize */ 1097 + handle = ocfs2_start_trans(OCFS2_SB(sb), 1098 + OCFS2_LOCAL_QINFO_WRITE_CREDITS + 1099 + 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS); 1119 1100 if (IS_ERR(handle)) { 1120 1101 status = PTR_ERR(handle); 1121 1102 mlog_errno(status); 1122 1103 goto out; 1123 1104 } 1105 + /* Zero created block */ 1106 + status = ocfs2_journal_access_dq(handle, lqinode, bh, 1107 + OCFS2_JOURNAL_ACCESS_CREATE); 1108 + if (status < 0) { 1109 + mlog_errno(status); 1110 + goto out_trans; 1111 + } 1112 + lock_buffer(bh); 1113 + memset(bh->b_data, 0, sb->s_blocksize); 1114 + unlock_buffer(bh); 1115 + status = ocfs2_journal_dirty(handle, bh); 1116 + if (status < 0) { 1117 + mlog_errno(status); 1118 + goto out_trans; 1119 + } 1120 + /* Update chunk header */ 1124 1121 status = ocfs2_journal_access_dq(handle, lqinode, chunk->qc_headerbh, 1125 1122 OCFS2_JOURNAL_ACCESS_WRITE); 1126 1123 if (status < 0) { ··· 1174 1097 mlog_errno(status); 1175 1098 goto out_trans; 1176 1099 } 1100 + /* Update file header */ 1177 1101 oinfo->dqi_blocks++; 1178 1102 status = ocfs2_local_write_info(sb, type); 1179 1103 if (status < 0) {
+2 -1
fs/ocfs2/stack_o2cb.c
··· 17 17 * General Public License for more details. 18 18 */ 19 19 20 + #include <linux/kernel.h> 20 21 #include <linux/crc32.h> 21 22 #include <linux/module.h> 22 23 ··· 154 153 155 154 static int dlm_status_to_errno(enum dlm_status status) 156 155 { 157 - BUG_ON(status > (sizeof(status_map) / sizeof(status_map[0]))); 156 + BUG_ON(status < 0 || status >= ARRAY_SIZE(status_map)); 158 157 159 158 return status_map[status]; 160 159 }
+26 -4
fs/ocfs2/super.c
··· 777 777 } 778 778 di = (struct ocfs2_dinode *) (*bh)->b_data; 779 779 memset(stats, 0, sizeof(struct ocfs2_blockcheck_stats)); 780 + spin_lock_init(&stats->b_lock); 780 781 status = ocfs2_verify_volume(di, *bh, blksize, stats); 781 782 if (status >= 0) 782 783 goto bail; ··· 1183 1182 wake_up(&osb->osb_mount_event); 1184 1183 1185 1184 /* Start this when the mount is almost sure of being successful */ 1186 - ocfs2_orphan_scan_init(osb); 1185 + ocfs2_orphan_scan_start(osb); 1187 1186 1188 1187 mlog_exit(status); 1189 1188 return status; ··· 1214 1213 mnt); 1215 1214 } 1216 1215 1216 + static void ocfs2_kill_sb(struct super_block *sb) 1217 + { 1218 + struct ocfs2_super *osb = OCFS2_SB(sb); 1219 + 1220 + /* Prevent further queueing of inode drop events */ 1221 + spin_lock(&dentry_list_lock); 1222 + ocfs2_set_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED); 1223 + spin_unlock(&dentry_list_lock); 1224 + /* Wait for work to finish and/or remove it */ 1225 + cancel_work_sync(&osb->dentry_lock_work); 1226 + 1227 + kill_block_super(sb); 1228 + } 1229 + 1217 1230 static struct file_system_type ocfs2_fs_type = { 1218 1231 .owner = THIS_MODULE, 1219 1232 .name = "ocfs2", 1220 1233 .get_sb = ocfs2_get_sb, /* is this called when we mount 1221 1234 * the fs? */ 1222 - .kill_sb = kill_block_super, /* set to the generic one 1223 - * right now, but do we 1224 - * need to change that? */ 1235 + .kill_sb = ocfs2_kill_sb, 1236 + 1225 1237 .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE, 1226 1238 .next = NULL 1227 1239 }; ··· 1833 1819 1834 1820 debugfs_remove(osb->osb_ctxt); 1835 1821 1822 + /* 1823 + * Flush inode dropping work queue so that deletes are 1824 + * performed while the filesystem is still working 1825 + */ 1826 + ocfs2_drop_all_dl_inodes(osb); 1827 + 1836 1828 /* Orphan scan should be stopped as early as possible */ 1837 1829 ocfs2_orphan_scan_stop(osb); 1838 1830 ··· 2000 1980 2001 1981 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", 2002 1982 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); 1983 + 1984 + ocfs2_orphan_scan_init(osb); 2003 1985 2004 1986 status = ocfs2_recovery_init(osb); 2005 1987 if (status) {
+2 -1
fs/ocfs2/xattr.c
··· 1052 1052 struct ocfs2_xattr_block *xb; 1053 1053 struct ocfs2_xattr_value_root *xv; 1054 1054 size_t size; 1055 - int ret = -ENODATA, name_offset, name_len, block_off, i; 1055 + int ret = -ENODATA, name_offset, name_len, i; 1056 + int uninitialized_var(block_off); 1056 1057 1057 1058 xs->bucket = ocfs2_xattr_bucket_new(inode); 1058 1059 if (!xs->bucket) {