Commit a5f28ae4 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2:
  ocfs2/cluster: Make o2net connect messages KERN_NOTICE
  ocfs2/dlm: Fix printing of lockname
  ocfs2: Fix contiguousness check in ocfs2_try_to_merge_extent_map()
  ocfs2/dlm: Remove BUG_ON in dlm recovery when freeing locks of a dead node
  ocfs2: Plugs race between the dc thread and an unlock ast message
  ocfs2: Remove overzealous BUG_ON during blocked lock processing
  ocfs2: Do not downconvert if the lock level is already compatible
  ocfs2: Prevent a livelock in dlmglue
  ocfs2: Fix setting of OCFS2_LOCK_BLOCKED during bast
  ocfs2: Use compat_ptr in reflink_arguments.
  ocfs2/dlm: Handle EAGAIN for compatibility - v2
  ocfs2: Add parenthesis to wrap the check for O_DIRECT.
  ocfs2: Only bug out when page size is larger than cluster size.
  ocfs2: Fix memory overflow in cow_by_page.
  ocfs2/dlm: Print more messages during lock migration
  ocfs2/dlm: Ignore LVBs of locks in the Blocked list
  ocfs2/trivial: Remove trailing whitespaces
  ocfs2: fix a misleading variable name
  ocfs2: Sync max_inline_data_with_xattr from tools.
  ocfs2: Fix refcnt leak on ocfs2_fast_follow_link() error path
parents 8defcaa6 6efd8066
...@@ -485,7 +485,7 @@ static void o2net_set_nn_state(struct o2net_node *nn, ...@@ -485,7 +485,7 @@ static void o2net_set_nn_state(struct o2net_node *nn,
} }
if (was_valid && !valid) { if (was_valid && !valid) {
printk(KERN_INFO "o2net: no longer connected to " printk(KERN_NOTICE "o2net: no longer connected to "
SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc)); SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc));
o2net_complete_nodes_nsw(nn); o2net_complete_nodes_nsw(nn);
} }
...@@ -493,7 +493,7 @@ static void o2net_set_nn_state(struct o2net_node *nn, ...@@ -493,7 +493,7 @@ static void o2net_set_nn_state(struct o2net_node *nn,
if (!was_valid && valid) { if (!was_valid && valid) {
o2quo_conn_up(o2net_num_from_nn(nn)); o2quo_conn_up(o2net_num_from_nn(nn));
cancel_delayed_work(&nn->nn_connect_expired); cancel_delayed_work(&nn->nn_connect_expired);
printk(KERN_INFO "o2net: %s " SC_NODEF_FMT "\n", printk(KERN_NOTICE "o2net: %s " SC_NODEF_FMT "\n",
o2nm_this_node() > sc->sc_node->nd_num ? o2nm_this_node() > sc->sc_node->nd_num ?
"connected to" : "accepted connection from", "connected to" : "accepted connection from",
SC_NODEF_ARGS(sc)); SC_NODEF_ARGS(sc));
...@@ -1476,7 +1476,7 @@ static void o2net_idle_timer(unsigned long data) ...@@ -1476,7 +1476,7 @@ static void o2net_idle_timer(unsigned long data)
do_gettimeofday(&now); do_gettimeofday(&now);
printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u " printk(KERN_NOTICE "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u "
"seconds, shutting it down.\n", SC_NODEF_ARGS(sc), "seconds, shutting it down.\n", SC_NODEF_ARGS(sc),
o2net_idle_timeout() / 1000, o2net_idle_timeout() / 1000,
o2net_idle_timeout() % 1000); o2net_idle_timeout() % 1000);
......
...@@ -102,7 +102,7 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res) ...@@ -102,7 +102,7 @@ void __dlm_print_one_lock_resource(struct dlm_lock_resource *res)
assert_spin_locked(&res->spinlock); assert_spin_locked(&res->spinlock);
stringify_lockname(res->lockname.name, res->lockname.len, stringify_lockname(res->lockname.name, res->lockname.len,
buf, sizeof(buf) - 1); buf, sizeof(buf));
printk("lockres: %s, owner=%u, state=%u\n", printk("lockres: %s, owner=%u, state=%u\n",
buf, res->owner, res->state); buf, res->owner, res->state);
printk(" last used: %lu, refcnt: %u, on purge list: %s\n", printk(" last used: %lu, refcnt: %u, on purge list: %s\n",
......
...@@ -1164,6 +1164,39 @@ static void dlm_init_migratable_lockres(struct dlm_migratable_lockres *mres, ...@@ -1164,6 +1164,39 @@ static void dlm_init_migratable_lockres(struct dlm_migratable_lockres *mres,
mres->master = master; mres->master = master;
} }
static void dlm_prepare_lvb_for_migration(struct dlm_lock *lock,
struct dlm_migratable_lockres *mres,
int queue)
{
if (!lock->lksb)
return;
/* Ignore lvb in all locks in the blocked list */
if (queue == DLM_BLOCKED_LIST)
return;
/* Only consider lvbs in locks with granted EX or PR lock levels */
if (lock->ml.type != LKM_EXMODE && lock->ml.type != LKM_PRMODE)
return;
if (dlm_lvb_is_empty(mres->lvb)) {
memcpy(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN);
return;
}
/* Ensure the lvb copied for migration matches in other valid locks */
if (!memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN))
return;
mlog(ML_ERROR, "Mismatched lvb in lock cookie=%u:%llu, name=%.*s, "
"node=%u\n",
dlm_get_lock_cookie_node(be64_to_cpu(lock->ml.cookie)),
dlm_get_lock_cookie_seq(be64_to_cpu(lock->ml.cookie)),
lock->lockres->lockname.len, lock->lockres->lockname.name,
lock->ml.node);
dlm_print_one_lock_resource(lock->lockres);
BUG();
}
/* returns 1 if this lock fills the network structure, /* returns 1 if this lock fills the network structure,
* 0 otherwise */ * 0 otherwise */
...@@ -1181,20 +1214,7 @@ static int dlm_add_lock_to_array(struct dlm_lock *lock, ...@@ -1181,20 +1214,7 @@ static int dlm_add_lock_to_array(struct dlm_lock *lock,
ml->list = queue; ml->list = queue;
if (lock->lksb) { if (lock->lksb) {
ml->flags = lock->lksb->flags; ml->flags = lock->lksb->flags;
/* send our current lvb */ dlm_prepare_lvb_for_migration(lock, mres, queue);
if (ml->type == LKM_EXMODE ||
ml->type == LKM_PRMODE) {
/* if it is already set, this had better be a PR
* and it has to match */
if (!dlm_lvb_is_empty(mres->lvb) &&
(ml->type == LKM_EXMODE ||
memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN))) {
mlog(ML_ERROR, "mismatched lvbs!\n");
dlm_print_one_lock_resource(lock->lockres);
BUG();
}
memcpy(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN);
}
} }
ml->node = lock->ml.node; ml->node = lock->ml.node;
mres->num_locks++; mres->num_locks++;
...@@ -1730,6 +1750,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, ...@@ -1730,6 +1750,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
struct dlm_lock *lock = NULL; struct dlm_lock *lock = NULL;
u8 from = O2NM_MAX_NODES; u8 from = O2NM_MAX_NODES;
unsigned int added = 0; unsigned int added = 0;
__be64 c;
mlog(0, "running %d locks for this lockres\n", mres->num_locks); mlog(0, "running %d locks for this lockres\n", mres->num_locks);
for (i=0; i<mres->num_locks; i++) { for (i=0; i<mres->num_locks; i++) {
...@@ -1777,19 +1798,48 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, ...@@ -1777,19 +1798,48 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
/* lock is always created locally first, and /* lock is always created locally first, and
* destroyed locally last. it must be on the list */ * destroyed locally last. it must be on the list */
if (!lock) { if (!lock) {
__be64 c = ml->cookie; c = ml->cookie;
mlog(ML_ERROR, "could not find local lock " mlog(ML_ERROR, "Could not find local lock "
"with cookie %u:%llu!\n", "with cookie %u:%llu, node %u, "
"list %u, flags 0x%x, type %d, "
"conv %d, highest blocked %d\n",
dlm_get_lock_cookie_node(be64_to_cpu(c)), dlm_get_lock_cookie_node(be64_to_cpu(c)),
dlm_get_lock_cookie_seq(be64_to_cpu(c))); dlm_get_lock_cookie_seq(be64_to_cpu(c)),
ml->node, ml->list, ml->flags, ml->type,
ml->convert_type, ml->highest_blocked);
__dlm_print_one_lock_resource(res);
BUG();
}
if (lock->ml.node != ml->node) {
c = lock->ml.cookie;
mlog(ML_ERROR, "Mismatched node# in lock "
"cookie %u:%llu, name %.*s, node %u\n",
dlm_get_lock_cookie_node(be64_to_cpu(c)),
dlm_get_lock_cookie_seq(be64_to_cpu(c)),
res->lockname.len, res->lockname.name,
lock->ml.node);
c = ml->cookie;
mlog(ML_ERROR, "Migrate lock cookie %u:%llu, "
"node %u, list %u, flags 0x%x, type %d, "
"conv %d, highest blocked %d\n",
dlm_get_lock_cookie_node(be64_to_cpu(c)),
dlm_get_lock_cookie_seq(be64_to_cpu(c)),
ml->node, ml->list, ml->flags, ml->type,
ml->convert_type, ml->highest_blocked);
__dlm_print_one_lock_resource(res); __dlm_print_one_lock_resource(res);
BUG(); BUG();
} }
BUG_ON(lock->ml.node != ml->node);
if (tmpq != queue) { if (tmpq != queue) {
mlog(0, "lock was on %u instead of %u for %.*s\n", c = ml->cookie;
j, ml->list, res->lockname.len, res->lockname.name); mlog(0, "Lock cookie %u:%llu was on list %u "
"instead of list %u for %.*s\n",
dlm_get_lock_cookie_node(be64_to_cpu(c)),
dlm_get_lock_cookie_seq(be64_to_cpu(c)),
j, ml->list, res->lockname.len,
res->lockname.name);
__dlm_print_one_lock_resource(res);
spin_unlock(&res->spinlock); spin_unlock(&res->spinlock);
continue; continue;
} }
...@@ -1886,7 +1936,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm, ...@@ -1886,7 +1936,7 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
spin_lock(&res->spinlock); spin_lock(&res->spinlock);
list_for_each_entry(lock, queue, list) { list_for_each_entry(lock, queue, list) {
if (lock->ml.cookie == ml->cookie) { if (lock->ml.cookie == ml->cookie) {
__be64 c = lock->ml.cookie; c = lock->ml.cookie;
mlog(ML_ERROR, "%s:%.*s: %u:%llu: lock already " mlog(ML_ERROR, "%s:%.*s: %u:%llu: lock already "
"exists on this lockres!\n", dlm->name, "exists on this lockres!\n", dlm->name,
res->lockname.len, res->lockname.name, res->lockname.len, res->lockname.name,
...@@ -2193,7 +2243,12 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm, ...@@ -2193,7 +2243,12 @@ static void dlm_free_dead_locks(struct dlm_ctxt *dlm,
mlog(0, "%s:%.*s: freed %u locks for dead node %u, " mlog(0, "%s:%.*s: freed %u locks for dead node %u, "
"dropping ref from lockres\n", dlm->name, "dropping ref from lockres\n", dlm->name,
res->lockname.len, res->lockname.name, freed, dead_node); res->lockname.len, res->lockname.name, freed, dead_node);
BUG_ON(!test_bit(dead_node, res->refmap)); if(!test_bit(dead_node, res->refmap)) {
mlog(ML_ERROR, "%s:%.*s: freed %u locks for dead node %u, "
"but ref was not set\n", dlm->name,
res->lockname.len, res->lockname.name, freed, dead_node);
__dlm_print_one_lock_resource(res);
}
dlm_lockres_clear_refmap_bit(dead_node, res); dlm_lockres_clear_refmap_bit(dead_node, res);
} else if (test_bit(dead_node, res->refmap)) { } else if (test_bit(dead_node, res->refmap)) {
mlog(0, "%s:%.*s: dead node %u had a ref, but had " mlog(0, "%s:%.*s: dead node %u had a ref, but had "
...@@ -2589,7 +2644,13 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node) ...@@ -2589,7 +2644,13 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node)
"begin reco msg (%d)\n", dlm->name, nodenum, ret); "begin reco msg (%d)\n", dlm->name, nodenum, ret);
ret = 0; ret = 0;
} }
if (ret == -EAGAIN) {
/*
* Prior to commit aad1b15310b9bcd59fa81ab8f2b1513b59553ea8,
* dlm_begin_reco_handler() returned EAGAIN and not -EAGAIN.
* We are handling both for compatibility reasons.
*/
if (ret == -EAGAIN || ret == EAGAIN) {
mlog(0, "%s: trying to start recovery of node " mlog(0, "%s: trying to start recovery of node "
"%u, but node %u is waiting for last recovery " "%u, but node %u is waiting for last recovery "
"to complete, backoff for a bit\n", dlm->name, "to complete, backoff for a bit\n", dlm->name,
......
...@@ -875,6 +875,14 @@ static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lo ...@@ -875,6 +875,14 @@ static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lo
lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH);
lockres->l_level = lockres->l_requested; lockres->l_level = lockres->l_requested;
/*
* We set the OCFS2_LOCK_UPCONVERT_FINISHING flag before clearing
* the OCFS2_LOCK_BUSY flag to prevent the dc thread from
* downconverting the lock before the upconvert has fully completed.
*/
lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING);
lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); lockres_clear_flags(lockres, OCFS2_LOCK_BUSY);
mlog_exit_void(); mlog_exit_void();
...@@ -907,8 +915,6 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, ...@@ -907,8 +915,6 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres,
assert_spin_locked(&lockres->l_lock); assert_spin_locked(&lockres->l_lock);
lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED);
if (level > lockres->l_blocking) { if (level > lockres->l_blocking) {
/* only schedule a downconvert if we haven't already scheduled /* only schedule a downconvert if we haven't already scheduled
* one that goes low enough to satisfy the level we're * one that goes low enough to satisfy the level we're
...@@ -921,6 +927,9 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, ...@@ -921,6 +927,9 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres,
lockres->l_blocking = level; lockres->l_blocking = level;
} }
if (needs_downconvert)
lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED);
mlog_exit(needs_downconvert); mlog_exit(needs_downconvert);
return needs_downconvert; return needs_downconvert;
} }
...@@ -1133,6 +1142,7 @@ static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, ...@@ -1133,6 +1142,7 @@ static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres,
mlog_entry_void(); mlog_entry_void();
spin_lock_irqsave(&lockres->l_lock, flags); spin_lock_irqsave(&lockres->l_lock, flags);
lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); lockres_clear_flags(lockres, OCFS2_LOCK_BUSY);
lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING);
if (convert) if (convert)
lockres->l_action = OCFS2_AST_INVALID; lockres->l_action = OCFS2_AST_INVALID;
else else
...@@ -1323,13 +1333,13 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb, ...@@ -1323,13 +1333,13 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
again: again:
wait = 0; wait = 0;
spin_lock_irqsave(&lockres->l_lock, flags);
if (catch_signals && signal_pending(current)) { if (catch_signals && signal_pending(current)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto out; goto unlock;
} }
spin_lock_irqsave(&lockres->l_lock, flags);
mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING, mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING,
"Cluster lock called on freeing lockres %s! flags " "Cluster lock called on freeing lockres %s! flags "
"0x%lx\n", lockres->l_name, lockres->l_flags); "0x%lx\n", lockres->l_name, lockres->l_flags);
...@@ -1346,6 +1356,25 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb, ...@@ -1346,6 +1356,25 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
goto unlock; goto unlock;
} }
if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING) {
/*
* We've upconverted. If the lock now has a level we can
* work with, we take it. If, however, the lock is not at the
* required level, we go thru the full cycle. One way this could
* happen is if a process requesting an upconvert to PR is
* closely followed by another requesting upconvert to an EX.
* If the process requesting EX lands here, we want it to
* continue attempting to upconvert and let the process
* requesting PR take the lock.
* If multiple processes request upconvert to PR, the first one
* here will take the lock. The others will have to go thru the
* OCFS2_LOCK_BLOCKED check to ensure that there is no pending
* downconvert request.
*/
if (level <= lockres->l_level)
goto update_holders;
}
if (lockres->l_flags & OCFS2_LOCK_BLOCKED && if (lockres->l_flags & OCFS2_LOCK_BLOCKED &&
!ocfs2_may_continue_on_blocked_lock(lockres, level)) { !ocfs2_may_continue_on_blocked_lock(lockres, level)) {
/* is the lock is currently blocked on behalf of /* is the lock is currently blocked on behalf of
...@@ -1416,11 +1445,14 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb, ...@@ -1416,11 +1445,14 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
goto again; goto again;
} }
update_holders:
/* Ok, if we get here then we're good to go. */ /* Ok, if we get here then we're good to go. */
ocfs2_inc_holders(lockres, level); ocfs2_inc_holders(lockres, level);
ret = 0; ret = 0;
unlock: unlock:
lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING);
spin_unlock_irqrestore(&lockres->l_lock, flags); spin_unlock_irqrestore(&lockres->l_lock, flags);
out: out:
/* /*
...@@ -3352,6 +3384,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, ...@@ -3352,6 +3384,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb,
unsigned long flags; unsigned long flags;
int blocking; int blocking;
int new_level; int new_level;
int level;
int ret = 0; int ret = 0;
int set_lvb = 0; int set_lvb = 0;
unsigned int gen; unsigned int gen;
...@@ -3360,9 +3393,17 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, ...@@ -3360,9 +3393,17 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb,
spin_lock_irqsave(&lockres->l_lock, flags); spin_lock_irqsave(&lockres->l_lock, flags);
BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED));
recheck: recheck:
/*
* Is it still blocking? If not, we have no more work to do.
*/
if (!(lockres->l_flags & OCFS2_LOCK_BLOCKED)) {
BUG_ON(lockres->l_blocking != DLM_LOCK_NL);
spin_unlock_irqrestore(&lockres->l_lock, flags);
ret = 0;
goto leave;
}
if (lockres->l_flags & OCFS2_LOCK_BUSY) { if (lockres->l_flags & OCFS2_LOCK_BUSY) {
/* XXX /* XXX
* This is a *big* race. The OCFS2_LOCK_PENDING flag * This is a *big* race. The OCFS2_LOCK_PENDING flag
...@@ -3401,6 +3442,31 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, ...@@ -3401,6 +3442,31 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb,
goto leave; goto leave;
} }
/*
* This prevents livelocks. OCFS2_LOCK_UPCONVERT_FINISHING flag is
* set when the ast is received for an upconvert just before the
* OCFS2_LOCK_BUSY flag is cleared. Now if the fs received a bast
* on the heels of the ast, we want to delay the downconvert just
* enough to allow the up requestor to do its task. Because this
* lock is in the blocked queue, the lock will be downconverted
* as soon as the requestor is done with the lock.
*/
if (lockres->l_flags & OCFS2_LOCK_UPCONVERT_FINISHING)
goto leave_requeue;
/*
* How can we block and yet be at NL? We were trying to upconvert
* from NL and got canceled. The code comes back here, and now
* we notice and clear BLOCKING.
*/
if (lockres->l_level == DLM_LOCK_NL) {
BUG_ON(lockres->l_ex_holders || lockres->l_ro_holders);
lockres->l_blocking = DLM_LOCK_NL;
lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED);
spin_unlock_irqrestore(&lockres->l_lock, flags);
goto leave;
}
/* if we're blocking an exclusive and we have *any* holders, /* if we're blocking an exclusive and we have *any* holders,
* then requeue. */ * then requeue. */
if ((lockres->l_blocking == DLM_LOCK_EX) if ((lockres->l_blocking == DLM_LOCK_EX)
...@@ -3438,6 +3504,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, ...@@ -3438,6 +3504,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb,
* may sleep, so we save off a copy of what we're blocking as * may sleep, so we save off a copy of what we're blocking as
* it may change while we're not holding the spin lock. */ * it may change while we're not holding the spin lock. */
blocking = lockres->l_blocking; blocking = lockres->l_blocking;
level = lockres->l_level;
spin_unlock_irqrestore(&lockres->l_lock, flags); spin_unlock_irqrestore(&lockres->l_lock, flags);
ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking); ctl->unblock_action = lockres->l_ops->downconvert_worker(lockres, blocking);
...@@ -3446,7 +3513,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, ...@@ -3446,7 +3513,7 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb,
goto leave; goto leave;
spin_lock_irqsave(&lockres->l_lock, flags); spin_lock_irqsave(&lockres->l_lock, flags);
if (blocking != lockres->l_blocking) { if ((blocking != lockres->l_blocking) || (level != lockres->l_level)) {
/* If this changed underneath us, then we can't drop /* If this changed underneath us, then we can't drop
* it just yet. */ * it just yet. */
goto recheck; goto recheck;
......
...@@ -192,7 +192,7 @@ static int ocfs2_try_to_merge_extent_map(struct ocfs2_extent_map_item *emi, ...@@ -192,7 +192,7 @@ static int ocfs2_try_to_merge_extent_map(struct ocfs2_extent_map_item *emi,
emi->ei_clusters += ins->ei_clusters; emi->ei_clusters += ins->ei_clusters;
return 1; return 1;
} else if ((ins->ei_phys + ins->ei_clusters) == emi->ei_phys && } else if ((ins->ei_phys + ins->ei_clusters) == emi->ei_phys &&
(ins->ei_cpos + ins->ei_clusters) == emi->ei_phys && (ins->ei_cpos + ins->ei_clusters) == emi->ei_cpos &&
ins->ei_flags == emi->ei_flags) { ins->ei_flags == emi->ei_flags) {
emi->ei_phys = ins->ei_phys; emi->ei_phys = ins->ei_phys;
emi->ei_cpos = ins->ei_cpos; emi->ei_cpos = ins->ei_cpos;
......
...@@ -2013,8 +2013,8 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, ...@@ -2013,8 +2013,8 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
/* buffered aio wouldn't have proper lock coverage today */ /* buffered aio wouldn't have proper lock coverage today */
BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
if ((file->f_flags & O_DSYNC && !direct_io) || IS_SYNC(inode) || if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) ||
(file->f_flags & O_DIRECT && has_refcount)) { ((file->f_flags & O_DIRECT) && has_refcount)) {
ret = filemap_fdatawrite_range(file->f_mapping, pos, ret = filemap_fdatawrite_range(file->f_mapping, pos,
pos + count - 1); pos + count - 1);
if (ret < 0) if (ret < 0)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/compat.h>
#define MLOG_MASK_PREFIX ML_INODE #define MLOG_MASK_PREFIX ML_INODE
#include <cluster/masklog.h> #include <cluster/masklog.h>
...@@ -181,6 +182,10 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -181,6 +182,10 @@ long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{ {
bool preserve;
struct reflink_arguments args;
struct inode *inode = file->f_path.dentry->d_inode;
switch (cmd) { switch (cmd) {
case OCFS2_IOC32_GETFLAGS: case OCFS2_IOC32_GETFLAGS:
cmd = OCFS2_IOC_GETFLAGS; cmd = OCFS2_IOC_GETFLAGS;
...@@ -195,8 +200,15 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg) ...@@ -195,8 +200,15 @@ long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
case OCFS2_IOC_GROUP_EXTEND: case OCFS2_IOC_GROUP_EXTEND:
case OCFS2_IOC_GROUP_ADD: case OCFS2_IOC_GROUP_ADD:
case OCFS2_IOC_GROUP_ADD64: case OCFS2_IOC_GROUP_ADD64:
case OCFS2_IOC_REFLINK:
break; break;
case OCFS2_IOC_REFLINK:
if (copy_from_user(&args, (struct reflink_arguments *)arg,
sizeof(args)))
return -EFAULT;
preserve = (args.preserve != 0);
return ocfs2_reflink_ioctl(inode, compat_ptr(args.old_path),
compat_ptr(args.new_path), preserve);
default: default:
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
......
...@@ -136,6 +136,10 @@ enum ocfs2_unlock_action { ...@@ -136,6 +136,10 @@ enum ocfs2_unlock_action {
#define OCFS2_LOCK_PENDING (0x00000400) /* This lockres is pending a #define OCFS2_LOCK_PENDING (0x00000400) /* This lockres is pending a
call to dlm_lock. Only call to dlm_lock. Only
exists with BUSY set. */ exists with BUSY set. */
#define OCFS2_LOCK_UPCONVERT_FINISHING (0x00000800) /* blocks the dc thread
* from downconverting
* before the upconvert
* has completed */
struct ocfs2_lock_res_ops; struct ocfs2_lock_res_ops;
......
...@@ -1417,9 +1417,16 @@ static inline int ocfs2_fast_symlink_chars(int blocksize) ...@@ -1417,9 +1417,16 @@ static inline int ocfs2_fast_symlink_chars(int blocksize)
return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink); return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
} }
static inline int ocfs2_max_inline_data(int blocksize) static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
struct ocfs2_dinode *di)
{ {
return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data); if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
return blocksize -
offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
di->i_xattr_inline_size;
else
return blocksize -
offsetof(struct ocfs2_dinode, id2.i_data.id_data);
} }
static inline int ocfs2_extent_recs_per_inode(int blocksize) static inline int ocfs2_extent_recs_per_inode(int blocksize)
......
...@@ -2945,7 +2945,7 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle, ...@@ -2945,7 +2945,7 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
while (offset < end) { while (offset < end) {
page_index = offset >> PAGE_CACHE_SHIFT; page_index = offset >> PAGE_CACHE_SHIFT;
map_end = (page_index + 1) << PAGE_CACHE_SHIFT; map_end = ((loff_t)page_index + 1) << PAGE_CACHE_SHIFT;
if (map_end > end) if (map_end > end)
map_end = end; map_end = end;
...@@ -2957,7 +2957,11 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle, ...@@ -2957,7 +2957,11 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
page = grab_cache_page(mapping, page_index); page = grab_cache_page(mapping, page_index);
/* This page can't be dirtied before we CoW it out. */ /*
* In case PAGE_CACHE_SIZE <= CLUSTER_SIZE, This page
* can't be dirtied before we CoW it out.
*/
if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
BUG_ON(PageDirty(page)); BUG_ON(PageDirty(page));
if (!PageUptodate(page)) { if (!PageUptodate(page)) {
...@@ -3170,7 +3174,7 @@ static int ocfs2_cow_sync_writeback(struct super_block *sb, ...@@ -3170,7 +3174,7 @@ static int ocfs2_cow_sync_writeback(struct super_block *sb,
while (offset < end) { while (offset < end) {
page_index = offset >> PAGE_CACHE_SHIFT; page_index = offset >> PAGE_CACHE_SHIFT;
map_end = (page_index + 1) << PAGE_CACHE_SHIFT; map_end = ((loff_t)page_index + 1) << PAGE_CACHE_SHIFT;
if (map_end > end) if (map_end > end)
map_end = end; map_end = end;
......
...@@ -277,7 +277,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) ...@@ -277,7 +277,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
u32 dlm_key; u32 dlm_key;
struct dlm_ctxt *dlm; struct dlm_ctxt *dlm;
struct o2dlm_private *priv; struct o2dlm_private *priv;
struct dlm_protocol_version dlm_version; struct dlm_protocol_version fs_version;
BUG_ON(conn == NULL); BUG_ON(conn == NULL);
BUG_ON(o2cb_stack.sp_proto == NULL); BUG_ON(o2cb_stack.sp_proto == NULL);
...@@ -304,18 +304,18 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) ...@@ -304,18 +304,18 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
/* used by the dlm code to make message headers unique, each /* used by the dlm code to make message headers unique, each
* node in this domain must agree on this. */ * node in this domain must agree on this. */
dlm_key = crc32_le(0, conn->cc_name, conn->cc_namelen); dlm_key = crc32_le(0, conn->cc_name, conn->cc_namelen);
dlm_version.pv_major = conn->cc_version.pv_major; fs_version.pv_major = conn->cc_version.pv_major;
dlm_version.pv_minor = conn->cc_version.pv_minor; fs_version.pv_minor = conn->cc_version.pv_minor;
dlm = dlm_register_domain(conn->cc_name, dlm_key, &dlm_version); dlm = dlm_register_domain(conn->cc_name, dlm_key, &fs_version);
if (IS_ERR(dlm)) { if (IS_ERR(dlm)) {
rc = PTR_ERR(dlm); rc = PTR_ERR(dlm);
mlog_errno(rc); mlog_errno(rc);
goto out_free; goto out_free;
} }
conn->cc_version.pv_major = dlm_version.pv_major; conn->cc_version.pv_major = fs_version.pv_major;
conn->cc_version.pv_minor = dlm_version.pv_minor; conn->cc_version.pv_minor = fs_version.pv_minor;
conn->cc_lockspace = dlm; conn->cc_lockspace = dlm;
dlm_register_eviction_cb(dlm, &priv->op_eviction_cb); dlm_register_eviction_cb(dlm, &priv->op_eviction_cb);
......
...@@ -137,19 +137,19 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry, ...@@ -137,19 +137,19 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry,
} }
memcpy(link, target, len); memcpy(link, target, len);
nd_set_link(nd, link);
bail: bail:
nd_set_link(nd, status ? ERR_PTR(status) : link);
brelse(bh); brelse(bh);
mlog_exit(status); mlog_exit(status);
return status ? ERR_PTR(status) : link; return NULL;
} }
static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
{ {
char *link = cookie; char *link = nd_get_link(nd);
if (!IS_ERR(link))
kfree(link); kfree(link);
} }
......
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