You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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: (47 commits) ocfs2: Silence a gcc warning. ocfs2: Don't retry xattr set in case value extension fails. ocfs2:dlm: avoid dlm->ast_lock lockres->spinlock dependency break ocfs2: Reset xattr value size after xa_cleanup_value_truncate(). fs/ocfs2/dlm: Use kstrdup fs/ocfs2/dlm: Drop memory allocation cast Ocfs2: Optimize punching-hole code. Ocfs2: Make ocfs2_find_cpos_for_left_leaf() public. Ocfs2: Fix hole punching to correctly do CoW during cluster zeroing. Ocfs2: Optimize ocfs2 truncate to use ocfs2_remove_btree_range() instead. ocfs2: Block signals for mkdir/link/symlink/O_CREAT. ocfs2: Wrap signal blocking in void functions. ocfs2/dlm: Increase o2dlm lockres hash size ocfs2: Make ocfs2_extend_trans() really extend. ocfs2/trivial: Code cleanup for allocation reservation. ocfs2: make ocfs2_adjust_resv_from_alloc simple. ocfs2: Make nointr a default mount option ocfs2/dlm: Make o2dlm domain join/leave messages KERN_NOTICE o2net: log socket state changes ocfs2: print node # when tcp fails ...
This commit is contained in:
@@ -80,3 +80,10 @@ user_xattr (*) Enables Extended User Attributes.
|
||||
nouser_xattr Disables Extended User Attributes.
|
||||
acl Enables POSIX Access Control Lists support.
|
||||
noacl (*) Disables POSIX Access Control Lists support.
|
||||
resv_level=2 (*) Set how agressive allocation reservations will be.
|
||||
Valid values are between 0 (reservations off) to 8
|
||||
(maximum space for reservations).
|
||||
dir_resv_level= (*) By default, directory reservations will scale with file
|
||||
reservations - users should rarely need to change this
|
||||
value. If allocation reservations are turned off, this
|
||||
option will have no effect.
|
||||
|
||||
@@ -29,6 +29,7 @@ ocfs2-objs := \
|
||||
mmap.o \
|
||||
namei.o \
|
||||
refcounttree.o \
|
||||
reservations.o \
|
||||
resize.o \
|
||||
slot_map.o \
|
||||
suballoc.o \
|
||||
|
||||
+219
-689
File diff suppressed because it is too large
Load Diff
+7
-5
@@ -140,8 +140,9 @@ int ocfs2_remove_extent(handle_t *handle, struct ocfs2_extent_tree *et,
|
||||
struct ocfs2_cached_dealloc_ctxt *dealloc);
|
||||
int ocfs2_remove_btree_range(struct inode *inode,
|
||||
struct ocfs2_extent_tree *et,
|
||||
u32 cpos, u32 phys_cpos, u32 len,
|
||||
struct ocfs2_cached_dealloc_ctxt *dealloc);
|
||||
u32 cpos, u32 phys_cpos, u32 len, int flags,
|
||||
struct ocfs2_cached_dealloc_ctxt *dealloc,
|
||||
u64 refcount_loc);
|
||||
|
||||
int ocfs2_num_free_extents(struct ocfs2_super *osb,
|
||||
struct ocfs2_extent_tree *et);
|
||||
@@ -209,7 +210,7 @@ static inline void ocfs2_init_dealloc_ctxt(struct ocfs2_cached_dealloc_ctxt *c)
|
||||
int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
|
||||
u64 blkno, unsigned int bit);
|
||||
int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt,
|
||||
int type, int slot, u64 blkno,
|
||||
int type, int slot, u64 suballoc, u64 blkno,
|
||||
unsigned int bit);
|
||||
static inline int ocfs2_dealloc_has_cluster(struct ocfs2_cached_dealloc_ctxt *c)
|
||||
{
|
||||
@@ -233,8 +234,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
|
||||
struct ocfs2_truncate_context **tc);
|
||||
int ocfs2_commit_truncate(struct ocfs2_super *osb,
|
||||
struct inode *inode,
|
||||
struct buffer_head *fe_bh,
|
||||
struct ocfs2_truncate_context *tc);
|
||||
struct buffer_head *di_bh);
|
||||
int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
|
||||
unsigned int start, unsigned int end, int trunc);
|
||||
|
||||
@@ -319,6 +319,8 @@ int ocfs2_journal_access_path(struct ocfs2_caching_info *ci,
|
||||
struct ocfs2_path *path);
|
||||
int ocfs2_find_cpos_for_right_leaf(struct super_block *sb,
|
||||
struct ocfs2_path *path, u32 *cpos);
|
||||
int ocfs2_find_cpos_for_left_leaf(struct super_block *sb,
|
||||
struct ocfs2_path *path, u32 *cpos);
|
||||
int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et,
|
||||
struct ocfs2_path *left,
|
||||
struct ocfs2_path *right);
|
||||
|
||||
@@ -1735,6 +1735,9 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (data_ac)
|
||||
data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
|
||||
|
||||
credits = ocfs2_calc_extend_credits(inode->i_sb,
|
||||
&di->id2.i_list,
|
||||
clusters_to_alloc);
|
||||
|
||||
@@ -116,6 +116,7 @@ static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = {
|
||||
define_mask(ERROR),
|
||||
define_mask(NOTICE),
|
||||
define_mask(KTHREAD),
|
||||
define_mask(RESERVATIONS),
|
||||
};
|
||||
|
||||
static struct attribute *mlog_attr_ptrs[MLOG_MAX_BITS] = {NULL, };
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
#define ML_ERROR 0x0000000100000000ULL /* sent to KERN_ERR */
|
||||
#define ML_NOTICE 0x0000000200000000ULL /* setn to KERN_NOTICE */
|
||||
#define ML_KTHREAD 0x0000000400000000ULL /* kernel thread activity */
|
||||
#define ML_RESERVATIONS 0x0000000800000000ULL /* ocfs2 alloc reservations */
|
||||
|
||||
#define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE)
|
||||
#define MLOG_INITIAL_NOT_MASK (ML_ENTRY|ML_EXIT)
|
||||
|
||||
@@ -583,6 +583,9 @@ static void o2net_state_change(struct sock *sk)
|
||||
o2net_sc_queue_work(sc, &sc->sc_connect_work);
|
||||
break;
|
||||
default:
|
||||
printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT
|
||||
" shutdown, state %d\n",
|
||||
SC_NODEF_ARGS(sc), sk->sk_state);
|
||||
o2net_sc_queue_work(sc, &sc->sc_shutdown_work);
|
||||
break;
|
||||
}
|
||||
|
||||
+27
-48
@@ -1194,7 +1194,7 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
|
||||
else
|
||||
de->inode = 0;
|
||||
dir->i_version++;
|
||||
status = ocfs2_journal_dirty(handle, bh);
|
||||
ocfs2_journal_dirty(handle, bh);
|
||||
goto bail;
|
||||
}
|
||||
i += le16_to_cpu(de->rec_len);
|
||||
@@ -1752,7 +1752,7 @@ int __ocfs2_add_entry(handle_t *handle,
|
||||
ocfs2_recalc_free_list(dir, handle, lookup);
|
||||
|
||||
dir->i_version++;
|
||||
status = ocfs2_journal_dirty(handle, insert_bh);
|
||||
ocfs2_journal_dirty(handle, insert_bh);
|
||||
retval = 0;
|
||||
goto bail;
|
||||
}
|
||||
@@ -2297,12 +2297,7 @@ static int ocfs2_fill_new_dir_id(struct ocfs2_super *osb,
|
||||
}
|
||||
|
||||
ocfs2_fill_initial_dirents(inode, parent, data->id_data, size);
|
||||
|
||||
ocfs2_journal_dirty(handle, di_bh);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
i_size_write(inode, size);
|
||||
inode->i_nlink = 2;
|
||||
@@ -2366,11 +2361,7 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
|
||||
ocfs2_init_dir_trailer(inode, new_bh, size);
|
||||
}
|
||||
|
||||
status = ocfs2_journal_dirty(handle, new_bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, new_bh);
|
||||
|
||||
i_size_write(inode, inode->i_sb->s_blocksize);
|
||||
inode->i_nlink = 2;
|
||||
@@ -2404,15 +2395,15 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
|
||||
int ret;
|
||||
struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
|
||||
u16 dr_suballoc_bit;
|
||||
u64 dr_blkno;
|
||||
u64 suballoc_loc, dr_blkno;
|
||||
unsigned int num_bits;
|
||||
struct buffer_head *dx_root_bh = NULL;
|
||||
struct ocfs2_dx_root_block *dx_root;
|
||||
struct ocfs2_dir_block_trailer *trailer =
|
||||
ocfs2_trailer_from_bh(dirdata_bh, dir->i_sb);
|
||||
|
||||
ret = ocfs2_claim_metadata(osb, handle, meta_ac, 1, &dr_suballoc_bit,
|
||||
&num_bits, &dr_blkno);
|
||||
ret = ocfs2_claim_metadata(handle, meta_ac, 1, &suballoc_loc,
|
||||
&dr_suballoc_bit, &num_bits, &dr_blkno);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
@@ -2440,6 +2431,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
|
||||
memset(dx_root, 0, osb->sb->s_blocksize);
|
||||
strcpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE);
|
||||
dx_root->dr_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
|
||||
dx_root->dr_suballoc_loc = cpu_to_le64(suballoc_loc);
|
||||
dx_root->dr_suballoc_bit = cpu_to_le16(dr_suballoc_bit);
|
||||
dx_root->dr_fs_generation = cpu_to_le32(osb->fs_generation);
|
||||
dx_root->dr_blkno = cpu_to_le64(dr_blkno);
|
||||
@@ -2458,10 +2450,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
|
||||
dx_root->dr_list.l_count =
|
||||
cpu_to_le16(ocfs2_extent_recs_per_dx_root(osb->sb));
|
||||
}
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, dx_root_bh);
|
||||
if (ret)
|
||||
mlog_errno(ret);
|
||||
ocfs2_journal_dirty(handle, dx_root_bh);
|
||||
|
||||
ret = ocfs2_journal_access_di(handle, INODE_CACHE(dir), di_bh,
|
||||
OCFS2_JOURNAL_ACCESS_CREATE);
|
||||
@@ -2475,9 +2464,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
|
||||
OCFS2_I(dir)->ip_dyn_features |= OCFS2_INDEXED_DIR_FL;
|
||||
di->i_dyn_features = cpu_to_le16(OCFS2_I(dir)->ip_dyn_features);
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, di_bh);
|
||||
if (ret)
|
||||
mlog_errno(ret);
|
||||
ocfs2_journal_dirty(handle, di_bh);
|
||||
|
||||
*ret_dx_root_bh = dx_root_bh;
|
||||
dx_root_bh = NULL;
|
||||
@@ -2558,7 +2545,7 @@ static int __ocfs2_dx_dir_new_cluster(struct inode *dir,
|
||||
* chance of contiguousness as the directory grows in number
|
||||
* of entries.
|
||||
*/
|
||||
ret = __ocfs2_claim_clusters(osb, handle, data_ac, 1, 1, &phys, &num);
|
||||
ret = __ocfs2_claim_clusters(handle, data_ac, 1, 1, &phys, &num);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
@@ -2991,7 +2978,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
|
||||
* if we only get one now, that's enough to continue. The rest
|
||||
* will be claimed after the conversion to extents.
|
||||
*/
|
||||
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len);
|
||||
if (ocfs2_dir_resv_allowed(osb))
|
||||
data_ac->ac_resv = &oi->ip_la_data_resv;
|
||||
ret = ocfs2_claim_clusters(handle, data_ac, 1, &bit_off, &len);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out_commit;
|
||||
@@ -3034,11 +3023,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
|
||||
ocfs2_init_dir_trailer(dir, dirdata_bh, i);
|
||||
}
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, dirdata_bh);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out_commit;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, dirdata_bh);
|
||||
|
||||
if (ocfs2_supports_indexed_dirs(osb) && !dx_inline) {
|
||||
/*
|
||||
@@ -3104,11 +3089,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
|
||||
*/
|
||||
dir->i_blocks = ocfs2_inode_sector_count(dir);
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, di_bh);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out_commit;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, di_bh);
|
||||
|
||||
if (ocfs2_supports_indexed_dirs(osb)) {
|
||||
ret = ocfs2_dx_dir_attach_index(osb, handle, dir, di_bh,
|
||||
@@ -3138,7 +3119,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
|
||||
* pass. Claim the 2nd cluster as a separate extent.
|
||||
*/
|
||||
if (alloc > len) {
|
||||
ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off,
|
||||
ret = ocfs2_claim_clusters(handle, data_ac, 1, &bit_off,
|
||||
&len);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
@@ -3369,6 +3350,9 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
|
||||
goto bail;
|
||||
}
|
||||
|
||||
if (ocfs2_dir_resv_allowed(osb))
|
||||
data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;
|
||||
|
||||
credits = ocfs2_calc_extend_credits(sb, el, 1);
|
||||
} else {
|
||||
spin_unlock(&OCFS2_I(dir)->ip_lock);
|
||||
@@ -3423,11 +3407,7 @@ do_extend:
|
||||
} else {
|
||||
de->rec_len = cpu_to_le16(sb->s_blocksize);
|
||||
}
|
||||
status = ocfs2_journal_dirty(handle, new_bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, new_bh);
|
||||
|
||||
dir_i_size += dir->i_sb->s_blocksize;
|
||||
i_size_write(dir, dir_i_size);
|
||||
@@ -3906,11 +3886,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir,
|
||||
sizeof(struct ocfs2_dx_entry), dx_leaf_sort_cmp,
|
||||
dx_leaf_sort_swap);
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, dx_leaf_bh);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out_commit;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, dx_leaf_bh);
|
||||
|
||||
ret = ocfs2_dx_dir_find_leaf_split(dx_leaf, leaf_cpos, insert_hash,
|
||||
&split_hash);
|
||||
@@ -4490,7 +4466,10 @@ static int ocfs2_dx_dir_remove_index(struct inode *dir,
|
||||
|
||||
blk = le64_to_cpu(dx_root->dr_blkno);
|
||||
bit = le16_to_cpu(dx_root->dr_suballoc_bit);
|
||||
bg_blkno = ocfs2_which_suballoc_group(blk, bit);
|
||||
if (dx_root->dr_suballoc_loc)
|
||||
bg_blkno = le64_to_cpu(dx_root->dr_suballoc_loc);
|
||||
else
|
||||
bg_blkno = ocfs2_which_suballoc_group(blk, bit);
|
||||
ret = ocfs2_free_suballoc_bits(handle, dx_alloc_inode, dx_alloc_bh,
|
||||
bit, bg_blkno, 1);
|
||||
if (ret)
|
||||
@@ -4551,8 +4530,8 @@ int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh)
|
||||
|
||||
p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno);
|
||||
|
||||
ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen,
|
||||
&dealloc);
|
||||
ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0,
|
||||
&dealloc, 0);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
|
||||
@@ -88,7 +88,7 @@ static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
{
|
||||
mlog_entry_void();
|
||||
|
||||
@@ -145,7 +145,7 @@ void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
}
|
||||
|
||||
|
||||
static void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
|
||||
{
|
||||
mlog_entry_void();
|
||||
|
||||
@@ -451,7 +451,9 @@ int dlm_send_proxy_ast_msg(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
|
||||
ret = o2net_send_message_vec(DLM_PROXY_AST_MSG, dlm->key, vec, veclen,
|
||||
lock->ml.node, &status);
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", ret, DLM_PROXY_AST_MSG, dlm->key,
|
||||
lock->ml.node);
|
||||
else {
|
||||
if (status == DLM_RECOVERING) {
|
||||
mlog(ML_ERROR, "sent AST to node %u, it thinks this "
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes
|
||||
#define DLM_THREAD_MS 200 // flush at least every 200 ms
|
||||
|
||||
#define DLM_HASH_SIZE_DEFAULT (1 << 14)
|
||||
#define DLM_HASH_SIZE_DEFAULT (1 << 17)
|
||||
#if DLM_HASH_SIZE_DEFAULT < PAGE_SIZE
|
||||
# define DLM_HASH_PAGES 1
|
||||
#else
|
||||
@@ -904,6 +904,8 @@ void __dlm_lockres_grab_inflight_ref(struct dlm_ctxt *dlm,
|
||||
|
||||
void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
|
||||
void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
|
||||
void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
|
||||
void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock);
|
||||
void dlm_do_local_ast(struct dlm_ctxt *dlm,
|
||||
struct dlm_lock_resource *res,
|
||||
struct dlm_lock *lock);
|
||||
|
||||
@@ -390,7 +390,9 @@ static enum dlm_status dlm_send_remote_convert_request(struct dlm_ctxt *dlm,
|
||||
} else if (ret != DLM_NORMAL && ret != DLM_NOTQUEUED)
|
||||
dlm_error(ret);
|
||||
} else {
|
||||
mlog_errno(tmpret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", tmpret, DLM_CONVERT_LOCK_MSG, dlm->key,
|
||||
res->owner);
|
||||
if (dlm_is_host_down(tmpret)) {
|
||||
/* instead of logging the same network error over
|
||||
* and over, sleep here and wait for the heartbeat
|
||||
|
||||
+17
-11
@@ -511,7 +511,7 @@ static void __dlm_print_nodes(struct dlm_ctxt *dlm)
|
||||
|
||||
assert_spin_locked(&dlm->spinlock);
|
||||
|
||||
printk(KERN_INFO "ocfs2_dlm: Nodes in domain (\"%s\"): ", dlm->name);
|
||||
printk(KERN_NOTICE "o2dlm: Nodes in domain %s: ", dlm->name);
|
||||
|
||||
while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES,
|
||||
node + 1)) < O2NM_MAX_NODES) {
|
||||
@@ -534,7 +534,7 @@ static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data,
|
||||
|
||||
node = exit_msg->node_idx;
|
||||
|
||||
printk(KERN_INFO "ocfs2_dlm: Node %u leaves domain %s\n", node, dlm->name);
|
||||
printk(KERN_NOTICE "o2dlm: Node %u leaves domain %s\n", node, dlm->name);
|
||||
|
||||
spin_lock(&dlm->spinlock);
|
||||
clear_bit(node, dlm->domain_map);
|
||||
@@ -565,7 +565,9 @@ static int dlm_send_one_domain_exit(struct dlm_ctxt *dlm,
|
||||
status = o2net_send_message(DLM_EXIT_DOMAIN_MSG, dlm->key,
|
||||
&leave_msg, sizeof(leave_msg), node,
|
||||
NULL);
|
||||
|
||||
if (status < 0)
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", status, DLM_EXIT_DOMAIN_MSG, dlm->key, node);
|
||||
mlog(0, "status return %d from o2net_send_message\n", status);
|
||||
|
||||
return status;
|
||||
@@ -904,7 +906,7 @@ static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data,
|
||||
set_bit(assert->node_idx, dlm->domain_map);
|
||||
__dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN);
|
||||
|
||||
printk(KERN_INFO "ocfs2_dlm: Node %u joins domain %s\n",
|
||||
printk(KERN_NOTICE "o2dlm: Node %u joins domain %s\n",
|
||||
assert->node_idx, dlm->name);
|
||||
__dlm_print_nodes(dlm);
|
||||
|
||||
@@ -962,7 +964,9 @@ static int dlm_send_one_join_cancel(struct dlm_ctxt *dlm,
|
||||
&cancel_msg, sizeof(cancel_msg), node,
|
||||
NULL);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", status, DLM_CANCEL_JOIN_MSG, DLM_MOD_KEY,
|
||||
node);
|
||||
goto bail;
|
||||
}
|
||||
|
||||
@@ -1029,10 +1033,11 @@ static int dlm_request_join(struct dlm_ctxt *dlm,
|
||||
byte_copymap(join_msg.node_map, dlm->live_nodes_map, O2NM_MAX_NODES);
|
||||
|
||||
status = o2net_send_message(DLM_QUERY_JOIN_MSG, DLM_MOD_KEY, &join_msg,
|
||||
sizeof(join_msg), node,
|
||||
&join_resp);
|
||||
sizeof(join_msg), node, &join_resp);
|
||||
if (status < 0 && status != -ENOPROTOOPT) {
|
||||
mlog_errno(status);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", status, DLM_QUERY_JOIN_MSG, DLM_MOD_KEY,
|
||||
node);
|
||||
goto bail;
|
||||
}
|
||||
dlm_query_join_wire_to_packet(join_resp, &packet);
|
||||
@@ -1103,7 +1108,9 @@ static int dlm_send_one_join_assert(struct dlm_ctxt *dlm,
|
||||
&assert_msg, sizeof(assert_msg), node,
|
||||
NULL);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", status, DLM_ASSERT_JOINED_MSG, DLM_MOD_KEY,
|
||||
node);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1516,7 +1523,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
dlm->name = kmalloc(strlen(domain) + 1, GFP_KERNEL);
|
||||
dlm->name = kstrdup(domain, GFP_KERNEL);
|
||||
if (dlm->name == NULL) {
|
||||
mlog_errno(-ENOMEM);
|
||||
kfree(dlm);
|
||||
@@ -1550,7 +1557,6 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
|
||||
for (i = 0; i < DLM_HASH_BUCKETS; i++)
|
||||
INIT_HLIST_HEAD(dlm_master_hash(dlm, i));
|
||||
|
||||
strcpy(dlm->name, domain);
|
||||
dlm->key = key;
|
||||
dlm->node_num = o2nm_this_node();
|
||||
|
||||
|
||||
@@ -329,7 +329,9 @@ static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm,
|
||||
BUG();
|
||||
}
|
||||
} else {
|
||||
mlog_errno(tmpret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", tmpret, DLM_CREATE_LOCK_MSG, dlm->key,
|
||||
res->owner);
|
||||
if (dlm_is_host_down(tmpret)) {
|
||||
ret = DLM_RECOVERING;
|
||||
mlog(0, "node %u died so returning DLM_RECOVERING "
|
||||
@@ -429,7 +431,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
|
||||
struct dlm_lock *lock;
|
||||
int kernel_allocated = 0;
|
||||
|
||||
lock = (struct dlm_lock *) kmem_cache_zalloc(dlm_lock_cache, GFP_NOFS);
|
||||
lock = kmem_cache_zalloc(dlm_lock_cache, GFP_NOFS);
|
||||
if (!lock)
|
||||
return NULL;
|
||||
|
||||
|
||||
+15
-15
@@ -617,13 +617,11 @@ struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm,
|
||||
{
|
||||
struct dlm_lock_resource *res = NULL;
|
||||
|
||||
res = (struct dlm_lock_resource *)
|
||||
kmem_cache_zalloc(dlm_lockres_cache, GFP_NOFS);
|
||||
res = kmem_cache_zalloc(dlm_lockres_cache, GFP_NOFS);
|
||||
if (!res)
|
||||
goto error;
|
||||
|
||||
res->lockname.name = (char *)
|
||||
kmem_cache_zalloc(dlm_lockname_cache, GFP_NOFS);
|
||||
res->lockname.name = kmem_cache_zalloc(dlm_lockname_cache, GFP_NOFS);
|
||||
if (!res->lockname.name)
|
||||
goto error;
|
||||
|
||||
@@ -757,8 +755,7 @@ lookup:
|
||||
spin_unlock(&dlm->spinlock);
|
||||
mlog(0, "allocating a new resource\n");
|
||||
/* nothing found and we need to allocate one. */
|
||||
alloc_mle = (struct dlm_master_list_entry *)
|
||||
kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
alloc_mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
if (!alloc_mle)
|
||||
goto leave;
|
||||
res = dlm_new_lockres(dlm, lockid, namelen);
|
||||
@@ -1542,8 +1539,7 @@ way_up_top:
|
||||
spin_unlock(&dlm->master_lock);
|
||||
spin_unlock(&dlm->spinlock);
|
||||
|
||||
mle = (struct dlm_master_list_entry *)
|
||||
kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
if (!mle) {
|
||||
response = DLM_MASTER_RESP_ERROR;
|
||||
mlog_errno(-ENOMEM);
|
||||
@@ -1666,7 +1662,9 @@ again:
|
||||
tmpret = o2net_send_message(DLM_ASSERT_MASTER_MSG, dlm->key,
|
||||
&assert, sizeof(assert), to, &r);
|
||||
if (tmpret < 0) {
|
||||
mlog(0, "assert_master returned %d!\n", tmpret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", tmpret,
|
||||
DLM_ASSERT_MASTER_MSG, dlm->key, to);
|
||||
if (!dlm_is_host_down(tmpret)) {
|
||||
mlog(ML_ERROR, "unhandled error=%d!\n", tmpret);
|
||||
BUG();
|
||||
@@ -2205,7 +2203,9 @@ int dlm_drop_lockres_ref(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
|
||||
ret = o2net_send_message(DLM_DEREF_LOCKRES_MSG, dlm->key,
|
||||
&deref, sizeof(deref), res->owner, &r);
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", ret, DLM_DEREF_LOCKRES_MSG, dlm->key,
|
||||
res->owner);
|
||||
else if (r < 0) {
|
||||
/* BAD. other node says I did not have a ref. */
|
||||
mlog(ML_ERROR,"while dropping ref on %s:%.*s "
|
||||
@@ -2452,8 +2452,7 @@ static int dlm_migrate_lockres(struct dlm_ctxt *dlm,
|
||||
goto leave;
|
||||
}
|
||||
|
||||
mle = (struct dlm_master_list_entry *) kmem_cache_alloc(dlm_mle_cache,
|
||||
GFP_NOFS);
|
||||
mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
if (!mle) {
|
||||
mlog_errno(ret);
|
||||
goto leave;
|
||||
@@ -2975,7 +2974,9 @@ static int dlm_do_migrate_request(struct dlm_ctxt *dlm,
|
||||
&migrate, sizeof(migrate), nodenum,
|
||||
&status);
|
||||
if (ret < 0) {
|
||||
mlog(0, "migrate_request returned %d!\n", ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_MIGRATE_REQUEST_MSG,
|
||||
dlm->key, nodenum);
|
||||
if (!dlm_is_host_down(ret)) {
|
||||
mlog(ML_ERROR, "unhandled error=%d!\n", ret);
|
||||
BUG();
|
||||
@@ -3033,8 +3034,7 @@ int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data,
|
||||
hash = dlm_lockid_hash(name, namelen);
|
||||
|
||||
/* preallocate.. if this fails, abort */
|
||||
mle = (struct dlm_master_list_entry *) kmem_cache_alloc(dlm_mle_cache,
|
||||
GFP_NOFS);
|
||||
mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
|
||||
|
||||
if (!mle) {
|
||||
ret = -ENOMEM;
|
||||
|
||||
@@ -803,7 +803,9 @@ static int dlm_request_all_locks(struct dlm_ctxt *dlm, u8 request_from,
|
||||
|
||||
/* negative status is handled by caller */
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_LOCK_REQUEST_MSG,
|
||||
dlm->key, request_from);
|
||||
|
||||
// return from here, then
|
||||
// sleep until all received or error
|
||||
@@ -955,10 +957,10 @@ static int dlm_send_all_done_msg(struct dlm_ctxt *dlm, u8 dead_node, u8 send_to)
|
||||
ret = o2net_send_message(DLM_RECO_DATA_DONE_MSG, dlm->key, &done_msg,
|
||||
sizeof(done_msg), send_to, &tmpret);
|
||||
if (ret < 0) {
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_RECO_DATA_DONE_MSG,
|
||||
dlm->key, send_to);
|
||||
if (!dlm_is_host_down(ret)) {
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "%s: unknown error sending data-done "
|
||||
"to %u\n", dlm->name, send_to);
|
||||
BUG();
|
||||
}
|
||||
} else
|
||||
@@ -1126,7 +1128,9 @@ static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm,
|
||||
if (ret < 0) {
|
||||
/* XXX: negative status is not handled.
|
||||
* this will end up killing this node. */
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_MIG_LOCKRES_MSG,
|
||||
dlm->key, send_to);
|
||||
} else {
|
||||
/* might get an -ENOMEM back here */
|
||||
ret = status;
|
||||
@@ -1642,7 +1646,9 @@ int dlm_do_master_requery(struct dlm_ctxt *dlm, struct dlm_lock_resource *res,
|
||||
&req, sizeof(req), nodenum, &status);
|
||||
/* XXX: negative status not handled properly here. */
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_MASTER_REQUERY_MSG,
|
||||
dlm->key, nodenum);
|
||||
else {
|
||||
BUG_ON(status < 0);
|
||||
BUG_ON(status > DLM_LOCK_RES_OWNER_UNKNOWN);
|
||||
@@ -2640,7 +2646,7 @@ retry:
|
||||
if (dlm_is_host_down(ret)) {
|
||||
/* node is down. not involved in recovery
|
||||
* so just keep going */
|
||||
mlog(0, "%s: node %u was down when sending "
|
||||
mlog(ML_NOTICE, "%s: node %u was down when sending "
|
||||
"begin reco msg (%d)\n", dlm->name, nodenum, ret);
|
||||
ret = 0;
|
||||
}
|
||||
@@ -2660,11 +2666,12 @@ retry:
|
||||
}
|
||||
if (ret < 0) {
|
||||
struct dlm_lock_resource *res;
|
||||
|
||||
/* this is now a serious problem, possibly ENOMEM
|
||||
* in the network stack. must retry */
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "begin reco of dlm %s to node %u "
|
||||
" returned %d\n", dlm->name, nodenum, ret);
|
||||
"returned %d\n", dlm->name, nodenum, ret);
|
||||
res = dlm_lookup_lockres(dlm, DLM_RECOVERY_LOCK_NAME,
|
||||
DLM_RECOVERY_LOCK_NAME_LEN);
|
||||
if (res) {
|
||||
@@ -2789,7 +2796,9 @@ stage2:
|
||||
if (ret >= 0)
|
||||
ret = status;
|
||||
if (ret < 0) {
|
||||
mlog_errno(ret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key "
|
||||
"0x%x) to node %u\n", ret, DLM_FINALIZE_RECO_MSG,
|
||||
dlm->key, nodenum);
|
||||
if (dlm_is_host_down(ret)) {
|
||||
/* this has no effect on this recovery
|
||||
* session, so set the status to zero to
|
||||
|
||||
@@ -309,6 +309,7 @@ static void dlm_shuffle_lists(struct dlm_ctxt *dlm,
|
||||
* spinlock, and because we know that it is not migrating/
|
||||
* recovering/in-progress, it is fine to reserve asts and
|
||||
* basts right before queueing them all throughout */
|
||||
assert_spin_locked(&dlm->ast_lock);
|
||||
assert_spin_locked(&res->spinlock);
|
||||
BUG_ON((res->state & (DLM_LOCK_RES_MIGRATING|
|
||||
DLM_LOCK_RES_RECOVERING|
|
||||
@@ -337,7 +338,7 @@ converting:
|
||||
/* queue the BAST if not already */
|
||||
if (lock->ml.highest_blocked == LKM_IVMODE) {
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_bast(dlm, lock);
|
||||
__dlm_queue_bast(dlm, lock);
|
||||
}
|
||||
/* update the highest_blocked if needed */
|
||||
if (lock->ml.highest_blocked < target->ml.convert_type)
|
||||
@@ -355,7 +356,7 @@ converting:
|
||||
can_grant = 0;
|
||||
if (lock->ml.highest_blocked == LKM_IVMODE) {
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_bast(dlm, lock);
|
||||
__dlm_queue_bast(dlm, lock);
|
||||
}
|
||||
if (lock->ml.highest_blocked < target->ml.convert_type)
|
||||
lock->ml.highest_blocked =
|
||||
@@ -383,7 +384,7 @@ converting:
|
||||
spin_unlock(&target->spinlock);
|
||||
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_ast(dlm, target);
|
||||
__dlm_queue_ast(dlm, target);
|
||||
/* go back and check for more */
|
||||
goto converting;
|
||||
}
|
||||
@@ -402,7 +403,7 @@ blocked:
|
||||
can_grant = 0;
|
||||
if (lock->ml.highest_blocked == LKM_IVMODE) {
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_bast(dlm, lock);
|
||||
__dlm_queue_bast(dlm, lock);
|
||||
}
|
||||
if (lock->ml.highest_blocked < target->ml.type)
|
||||
lock->ml.highest_blocked = target->ml.type;
|
||||
@@ -418,7 +419,7 @@ blocked:
|
||||
can_grant = 0;
|
||||
if (lock->ml.highest_blocked == LKM_IVMODE) {
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_bast(dlm, lock);
|
||||
__dlm_queue_bast(dlm, lock);
|
||||
}
|
||||
if (lock->ml.highest_blocked < target->ml.type)
|
||||
lock->ml.highest_blocked = target->ml.type;
|
||||
@@ -444,7 +445,7 @@ blocked:
|
||||
spin_unlock(&target->spinlock);
|
||||
|
||||
__dlm_lockres_reserve_ast(res);
|
||||
dlm_queue_ast(dlm, target);
|
||||
__dlm_queue_ast(dlm, target);
|
||||
/* go back and check for more */
|
||||
goto converting;
|
||||
}
|
||||
@@ -674,6 +675,7 @@ static int dlm_thread(void *data)
|
||||
/* lockres can be re-dirtied/re-added to the
|
||||
* dirty_list in this gap, but that is ok */
|
||||
|
||||
spin_lock(&dlm->ast_lock);
|
||||
spin_lock(&res->spinlock);
|
||||
if (res->owner != dlm->node_num) {
|
||||
__dlm_print_one_lock_resource(res);
|
||||
@@ -694,6 +696,7 @@ static int dlm_thread(void *data)
|
||||
/* move it to the tail and keep going */
|
||||
res->state &= ~DLM_LOCK_RES_DIRTY;
|
||||
spin_unlock(&res->spinlock);
|
||||
spin_unlock(&dlm->ast_lock);
|
||||
mlog(0, "delaying list shuffling for in-"
|
||||
"progress lockres %.*s, state=%d\n",
|
||||
res->lockname.len, res->lockname.name,
|
||||
@@ -715,6 +718,7 @@ static int dlm_thread(void *data)
|
||||
dlm_shuffle_lists(dlm, res);
|
||||
res->state &= ~DLM_LOCK_RES_DIRTY;
|
||||
spin_unlock(&res->spinlock);
|
||||
spin_unlock(&dlm->ast_lock);
|
||||
|
||||
dlm_lockres_calc_usage(dlm, res);
|
||||
|
||||
|
||||
@@ -354,7 +354,8 @@ static enum dlm_status dlm_send_remote_unlock_request(struct dlm_ctxt *dlm,
|
||||
mlog(0, "master was in-progress. retry\n");
|
||||
ret = status;
|
||||
} else {
|
||||
mlog_errno(tmpret);
|
||||
mlog(ML_ERROR, "Error %d when sending message %u (key 0x%x) to "
|
||||
"node %u\n", tmpret, DLM_UNLOCK_LOCK_MSG, dlm->key, owner);
|
||||
if (dlm_is_host_down(tmpret)) {
|
||||
/* NOTE: this seems strange, but it is what we want.
|
||||
* when the master goes down during a cancel or
|
||||
|
||||
+171
-46
@@ -278,10 +278,7 @@ int ocfs2_update_inode_atime(struct inode *inode,
|
||||
inode->i_atime = CURRENT_TIME;
|
||||
di->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
|
||||
di->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, bh);
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
ocfs2_journal_dirty(handle, bh);
|
||||
|
||||
out_commit:
|
||||
ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
|
||||
@@ -430,9 +427,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
|
||||
di->i_ctime = di->i_mtime = cpu_to_le64(inode->i_ctime.tv_sec);
|
||||
di->i_ctime_nsec = di->i_mtime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
|
||||
|
||||
status = ocfs2_journal_dirty(handle, fe_bh);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
ocfs2_journal_dirty(handle, fe_bh);
|
||||
|
||||
out_commit:
|
||||
ocfs2_commit_trans(osb, handle);
|
||||
@@ -449,7 +444,6 @@ static int ocfs2_truncate_file(struct inode *inode,
|
||||
int status = 0;
|
||||
struct ocfs2_dinode *fe = NULL;
|
||||
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
|
||||
struct ocfs2_truncate_context *tc = NULL;
|
||||
|
||||
mlog_entry("(inode = %llu, new_i_size = %llu\n",
|
||||
(unsigned long long)OCFS2_I(inode)->ip_blkno,
|
||||
@@ -488,6 +482,9 @@ static int ocfs2_truncate_file(struct inode *inode,
|
||||
|
||||
down_write(&OCFS2_I(inode)->ip_alloc_sem);
|
||||
|
||||
ocfs2_resv_discard(&osb->osb_la_resmap,
|
||||
&OCFS2_I(inode)->ip_la_data_resv);
|
||||
|
||||
/*
|
||||
* The inode lock forced other nodes to sync and drop their
|
||||
* pages, which (correctly) happens even if we have a truncate
|
||||
@@ -517,13 +514,7 @@ static int ocfs2_truncate_file(struct inode *inode,
|
||||
goto bail_unlock_sem;
|
||||
}
|
||||
|
||||
status = ocfs2_prepare_truncate(osb, inode, di_bh, &tc);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail_unlock_sem;
|
||||
}
|
||||
|
||||
status = ocfs2_commit_truncate(osb, inode, di_bh, tc);
|
||||
status = ocfs2_commit_truncate(osb, inode, di_bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail_unlock_sem;
|
||||
@@ -666,11 +657,7 @@ restarted_transaction:
|
||||
goto leave;
|
||||
}
|
||||
|
||||
status = ocfs2_journal_dirty(handle, bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto leave;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, bh);
|
||||
|
||||
spin_lock(&OCFS2_I(inode)->ip_lock);
|
||||
clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters);
|
||||
@@ -1195,9 +1182,7 @@ static int __ocfs2_write_remove_suid(struct inode *inode,
|
||||
di = (struct ocfs2_dinode *) bh->b_data;
|
||||
di->i_mode = cpu_to_le16(inode->i_mode);
|
||||
|
||||
ret = ocfs2_journal_dirty(handle, bh);
|
||||
if (ret < 0)
|
||||
mlog_errno(ret);
|
||||
ocfs2_journal_dirty(handle, bh);
|
||||
|
||||
out_trans:
|
||||
ocfs2_commit_trans(osb, handle);
|
||||
@@ -1434,16 +1419,90 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ocfs2_find_rec(struct ocfs2_extent_list *el, u32 pos)
|
||||
{
|
||||
int i;
|
||||
struct ocfs2_extent_rec *rec = NULL;
|
||||
|
||||
for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
|
||||
|
||||
rec = &el->l_recs[i];
|
||||
|
||||
if (le32_to_cpu(rec->e_cpos) < pos)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper to calculate the punching pos and length in one run, we handle the
|
||||
* following three cases in order:
|
||||
*
|
||||
* - remove the entire record
|
||||
* - remove a partial record
|
||||
* - no record needs to be removed (hole-punching completed)
|
||||
*/
|
||||
static void ocfs2_calc_trunc_pos(struct inode *inode,
|
||||
struct ocfs2_extent_list *el,
|
||||
struct ocfs2_extent_rec *rec,
|
||||
u32 trunc_start, u32 *trunc_cpos,
|
||||
u32 *trunc_len, u32 *trunc_end,
|
||||
u64 *blkno, int *done)
|
||||
{
|
||||
int ret = 0;
|
||||
u32 coff, range;
|
||||
|
||||
range = le32_to_cpu(rec->e_cpos) + ocfs2_rec_clusters(el, rec);
|
||||
|
||||
if (le32_to_cpu(rec->e_cpos) >= trunc_start) {
|
||||
*trunc_cpos = le32_to_cpu(rec->e_cpos);
|
||||
/*
|
||||
* Skip holes if any.
|
||||
*/
|
||||
if (range < *trunc_end)
|
||||
*trunc_end = range;
|
||||
*trunc_len = *trunc_end - le32_to_cpu(rec->e_cpos);
|
||||
*blkno = le64_to_cpu(rec->e_blkno);
|
||||
*trunc_end = le32_to_cpu(rec->e_cpos);
|
||||
} else if (range > trunc_start) {
|
||||
*trunc_cpos = trunc_start;
|
||||
*trunc_len = *trunc_end - trunc_start;
|
||||
coff = trunc_start - le32_to_cpu(rec->e_cpos);
|
||||
*blkno = le64_to_cpu(rec->e_blkno) +
|
||||
ocfs2_clusters_to_blocks(inode->i_sb, coff);
|
||||
*trunc_end = trunc_start;
|
||||
} else {
|
||||
/*
|
||||
* It may have two following possibilities:
|
||||
*
|
||||
* - last record has been removed
|
||||
* - trunc_start was within a hole
|
||||
*
|
||||
* both two cases mean the completion of hole punching.
|
||||
*/
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
*done = ret;
|
||||
}
|
||||
|
||||
static int ocfs2_remove_inode_range(struct inode *inode,
|
||||
struct buffer_head *di_bh, u64 byte_start,
|
||||
u64 byte_len)
|
||||
{
|
||||
int ret = 0;
|
||||
u32 trunc_start, trunc_len, cpos, phys_cpos, alloc_size;
|
||||
int ret = 0, flags = 0, done = 0, i;
|
||||
u32 trunc_start, trunc_len, trunc_end, trunc_cpos, phys_cpos;
|
||||
u32 cluster_in_el;
|
||||
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
|
||||
struct ocfs2_cached_dealloc_ctxt dealloc;
|
||||
struct address_space *mapping = inode->i_mapping;
|
||||
struct ocfs2_extent_tree et;
|
||||
struct ocfs2_path *path = NULL;
|
||||
struct ocfs2_extent_list *el = NULL;
|
||||
struct ocfs2_extent_rec *rec = NULL;
|
||||
struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
|
||||
u64 blkno, refcount_loc = le64_to_cpu(di->i_refcount_loc);
|
||||
|
||||
ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh);
|
||||
ocfs2_init_dealloc_ctxt(&dealloc);
|
||||
@@ -1469,17 +1528,35 @@ static int ocfs2_remove_inode_range(struct inode *inode,
|
||||
goto out;
|
||||
}
|
||||
|
||||
trunc_start = ocfs2_clusters_for_bytes(osb->sb, byte_start);
|
||||
trunc_len = (byte_start + byte_len) >> osb->s_clustersize_bits;
|
||||
if (trunc_len >= trunc_start)
|
||||
trunc_len -= trunc_start;
|
||||
else
|
||||
trunc_len = 0;
|
||||
/*
|
||||
* For reflinks, we may need to CoW 2 clusters which might be
|
||||
* partially zero'd later, if hole's start and end offset were
|
||||
* within one cluster(means is not exactly aligned to clustersize).
|
||||
*/
|
||||
|
||||
mlog(0, "Inode: %llu, start: %llu, len: %llu, cstart: %u, clen: %u\n",
|
||||
if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) {
|
||||
|
||||
ret = ocfs2_cow_file_pos(inode, di_bh, byte_start);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ocfs2_cow_file_pos(inode, di_bh, byte_start + byte_len);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
trunc_start = ocfs2_clusters_for_bytes(osb->sb, byte_start);
|
||||
trunc_end = (byte_start + byte_len) >> osb->s_clustersize_bits;
|
||||
cluster_in_el = trunc_end;
|
||||
|
||||
mlog(0, "Inode: %llu, start: %llu, len: %llu, cstart: %u, cend: %u\n",
|
||||
(unsigned long long)OCFS2_I(inode)->ip_blkno,
|
||||
(unsigned long long)byte_start,
|
||||
(unsigned long long)byte_len, trunc_start, trunc_len);
|
||||
(unsigned long long)byte_len, trunc_start, trunc_end);
|
||||
|
||||
ret = ocfs2_zero_partial_clusters(inode, byte_start, byte_len);
|
||||
if (ret) {
|
||||
@@ -1487,31 +1564,79 @@ static int ocfs2_remove_inode_range(struct inode *inode,
|
||||
goto out;
|
||||
}
|
||||
|
||||
cpos = trunc_start;
|
||||
while (trunc_len) {
|
||||
ret = ocfs2_get_clusters(inode, cpos, &phys_cpos,
|
||||
&alloc_size, NULL);
|
||||
path = ocfs2_new_path_from_et(&et);
|
||||
if (!path) {
|
||||
ret = -ENOMEM;
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (trunc_end > trunc_start) {
|
||||
|
||||
ret = ocfs2_find_path(INODE_CACHE(inode), path,
|
||||
cluster_in_el);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (alloc_size > trunc_len)
|
||||
alloc_size = trunc_len;
|
||||
el = path_leaf_el(path);
|
||||
|
||||
/* Only do work for non-holes */
|
||||
if (phys_cpos != 0) {
|
||||
ret = ocfs2_remove_btree_range(inode, &et, cpos,
|
||||
phys_cpos, alloc_size,
|
||||
&dealloc);
|
||||
i = ocfs2_find_rec(el, trunc_end);
|
||||
/*
|
||||
* Need to go to previous extent block.
|
||||
*/
|
||||
if (i < 0) {
|
||||
if (path->p_tree_depth == 0)
|
||||
break;
|
||||
|
||||
ret = ocfs2_find_cpos_for_left_leaf(inode->i_sb,
|
||||
path,
|
||||
&cluster_in_el);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* We've reached the leftmost extent block,
|
||||
* it's safe to leave.
|
||||
*/
|
||||
if (cluster_in_el == 0)
|
||||
break;
|
||||
|
||||
/*
|
||||
* The 'pos' searched for previous extent block is
|
||||
* always one cluster less than actual trunc_end.
|
||||
*/
|
||||
trunc_end = cluster_in_el + 1;
|
||||
|
||||
ocfs2_reinit_path(path, 1);
|
||||
|
||||
continue;
|
||||
|
||||
} else
|
||||
rec = &el->l_recs[i];
|
||||
|
||||
ocfs2_calc_trunc_pos(inode, el, rec, trunc_start, &trunc_cpos,
|
||||
&trunc_len, &trunc_end, &blkno, &done);
|
||||
if (done)
|
||||
break;
|
||||
|
||||
flags = rec->e_flags;
|
||||
phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
|
||||
|
||||
ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos,
|
||||
phys_cpos, trunc_len, flags,
|
||||
&dealloc, refcount_loc);
|
||||
if (ret < 0) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
cpos += alloc_size;
|
||||
trunc_len -= alloc_size;
|
||||
cluster_in_el = trunc_end;
|
||||
|
||||
ocfs2_reinit_path(path, 1);
|
||||
}
|
||||
|
||||
ocfs2_truncate_cluster_pages(inode, byte_start, byte_len);
|
||||
|
||||
+14
-31
@@ -376,6 +376,10 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
|
||||
|
||||
OCFS2_I(inode)->ip_last_used_slot = 0;
|
||||
OCFS2_I(inode)->ip_last_used_group = 0;
|
||||
|
||||
if (S_ISDIR(inode->i_mode))
|
||||
ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv,
|
||||
OCFS2_RESV_FLAG_DIR);
|
||||
mlog_exit_void();
|
||||
}
|
||||
|
||||
@@ -539,7 +543,6 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
|
||||
struct buffer_head *fe_bh)
|
||||
{
|
||||
int status = 0;
|
||||
struct ocfs2_truncate_context *tc = NULL;
|
||||
struct ocfs2_dinode *fe;
|
||||
handle_t *handle = NULL;
|
||||
|
||||
@@ -582,13 +585,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
|
||||
ocfs2_commit_trans(osb, handle);
|
||||
handle = NULL;
|
||||
|
||||
status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = ocfs2_commit_truncate(osb, inode, fe_bh, tc);
|
||||
status = ocfs2_commit_truncate(osb, inode, fe_bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto out;
|
||||
@@ -659,12 +656,7 @@ static int ocfs2_remove_inode(struct inode *inode,
|
||||
|
||||
di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec);
|
||||
di->i_flags &= cpu_to_le32(~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL));
|
||||
|
||||
status = ocfs2_journal_dirty(handle, di_bh);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail_commit;
|
||||
}
|
||||
ocfs2_journal_dirty(handle, di_bh);
|
||||
|
||||
ocfs2_remove_from_cache(INODE_CACHE(inode), di_bh);
|
||||
dquot_free_inode(inode);
|
||||
@@ -980,7 +972,7 @@ static void ocfs2_cleanup_delete_inode(struct inode *inode,
|
||||
void ocfs2_delete_inode(struct inode *inode)
|
||||
{
|
||||
int wipe, status;
|
||||
sigset_t blocked, oldset;
|
||||
sigset_t oldset;
|
||||
struct buffer_head *di_bh = NULL;
|
||||
|
||||
mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
|
||||
@@ -1007,13 +999,7 @@ void ocfs2_delete_inode(struct inode *inode)
|
||||
* messaging paths may return us -ERESTARTSYS. Which would
|
||||
* cause us to exit early, resulting in inodes being orphaned
|
||||
* forever. */
|
||||
sigfillset(&blocked);
|
||||
status = sigprocmask(SIG_BLOCK, &blocked, &oldset);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
ocfs2_cleanup_delete_inode(inode, 1);
|
||||
goto bail;
|
||||
}
|
||||
ocfs2_block_signals(&oldset);
|
||||
|
||||
/*
|
||||
* Synchronize us against ocfs2_get_dentry. We take this in
|
||||
@@ -1087,9 +1073,7 @@ bail_unlock_nfs_sync:
|
||||
ocfs2_nfs_sync_unlock(OCFS2_SB(inode->i_sb), 0);
|
||||
|
||||
bail_unblock:
|
||||
status = sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
ocfs2_unblock_signals(&oldset);
|
||||
bail:
|
||||
clear_inode(inode);
|
||||
mlog_exit_void();
|
||||
@@ -1123,6 +1107,10 @@ void ocfs2_clear_inode(struct inode *inode)
|
||||
ocfs2_mark_lockres_freeing(&oi->ip_inode_lockres);
|
||||
ocfs2_mark_lockres_freeing(&oi->ip_open_lockres);
|
||||
|
||||
ocfs2_resv_discard(&OCFS2_SB(inode->i_sb)->osb_la_resmap,
|
||||
&oi->ip_la_data_resv);
|
||||
ocfs2_resv_init_once(&oi->ip_la_data_resv);
|
||||
|
||||
/* We very well may get a clear_inode before all an inodes
|
||||
* metadata has hit disk. Of course, we can't drop any cluster
|
||||
* locks until the journal has finished with it. The only
|
||||
@@ -1298,13 +1286,8 @@ int ocfs2_mark_inode_dirty(handle_t *handle,
|
||||
fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
|
||||
fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
|
||||
|
||||
status = ocfs2_journal_dirty(handle, bh);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
|
||||
status = 0;
|
||||
ocfs2_journal_dirty(handle, bh);
|
||||
leave:
|
||||
|
||||
mlog_exit(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user