mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 09:31:50 +00:00
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/mfasheh/ocfs2: ocfs2_dlm: Add missing locks in dlm_empty_lockres ocfs2_dlm: Missing get/put lockres in dlm_run_purge_lockres configfs: add missing mutex_unlock() ocfs2: add some missing address space callbacks ocfs2: Concurrent access of o2hb_region->hr_task was not locked ocfs2: Proper cleanup in case of error in ocfs2_register_hb_callbacks()
This commit is contained in:
commit
4e337adae4
@ -1141,23 +1141,20 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
|
||||
|
||||
err = -ENOMEM;
|
||||
dentry = d_alloc(configfs_sb->s_root, &name);
|
||||
if (!dentry)
|
||||
goto out_release;
|
||||
|
||||
if (dentry) {
|
||||
d_add(dentry, NULL);
|
||||
|
||||
err = configfs_attach_group(sd->s_element, &group->cg_item,
|
||||
dentry);
|
||||
if (!err)
|
||||
dentry = NULL;
|
||||
else
|
||||
if (err) {
|
||||
d_delete(dentry);
|
||||
dput(dentry);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
|
||||
|
||||
if (dentry) {
|
||||
dput(dentry);
|
||||
out_release:
|
||||
if (err) {
|
||||
unlink_group(group);
|
||||
configfs_release_fs();
|
||||
}
|
||||
|
@ -614,6 +614,27 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
|
||||
ocfs2_rw_unlock(inode, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ocfs2_invalidatepage() and ocfs2_releasepage() are shamelessly stolen
|
||||
* from ext3. PageChecked() bits have been removed as OCFS2 does not
|
||||
* do journalled data.
|
||||
*/
|
||||
static void ocfs2_invalidatepage(struct page *page, unsigned long offset)
|
||||
{
|
||||
journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
|
||||
|
||||
journal_invalidatepage(journal, page, offset);
|
||||
}
|
||||
|
||||
static int ocfs2_releasepage(struct page *page, gfp_t wait)
|
||||
{
|
||||
journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
|
||||
|
||||
if (!page_has_buffers(page))
|
||||
return 0;
|
||||
return journal_try_to_free_buffers(journal, page, wait);
|
||||
}
|
||||
|
||||
static ssize_t ocfs2_direct_IO(int rw,
|
||||
struct kiocb *iocb,
|
||||
const struct iovec *iov,
|
||||
@ -661,5 +682,8 @@ const struct address_space_operations ocfs2_aops = {
|
||||
.commit_write = ocfs2_commit_write,
|
||||
.bmap = ocfs2_bmap,
|
||||
.sync_page = block_sync_page,
|
||||
.direct_IO = ocfs2_direct_IO
|
||||
.direct_IO = ocfs2_direct_IO,
|
||||
.invalidatepage = ocfs2_invalidatepage,
|
||||
.releasepage = ocfs2_releasepage,
|
||||
.migratepage = buffer_migrate_page,
|
||||
};
|
||||
|
@ -1234,6 +1234,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
|
||||
const char *page,
|
||||
size_t count)
|
||||
{
|
||||
struct task_struct *hb_task;
|
||||
long fd;
|
||||
int sectsize;
|
||||
char *p = (char *)page;
|
||||
@ -1319,20 +1320,28 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
|
||||
*/
|
||||
atomic_set(®->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1);
|
||||
|
||||
reg->hr_task = kthread_run(o2hb_thread, reg, "o2hb-%s",
|
||||
hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s",
|
||||
reg->hr_item.ci_name);
|
||||
if (IS_ERR(reg->hr_task)) {
|
||||
ret = PTR_ERR(reg->hr_task);
|
||||
if (IS_ERR(hb_task)) {
|
||||
ret = PTR_ERR(hb_task);
|
||||
mlog_errno(ret);
|
||||
reg->hr_task = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
spin_lock(&o2hb_live_lock);
|
||||
reg->hr_task = hb_task;
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
|
||||
ret = wait_event_interruptible(o2hb_steady_queue,
|
||||
atomic_read(®->hr_steady_iterations) == 0);
|
||||
if (ret) {
|
||||
kthread_stop(reg->hr_task);
|
||||
spin_lock(&o2hb_live_lock);
|
||||
hb_task = reg->hr_task;
|
||||
reg->hr_task = NULL;
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
|
||||
if (hb_task)
|
||||
kthread_stop(hb_task);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -1354,10 +1363,17 @@ out:
|
||||
static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
|
||||
char *page)
|
||||
{
|
||||
if (!reg->hr_task)
|
||||
pid_t pid = 0;
|
||||
|
||||
spin_lock(&o2hb_live_lock);
|
||||
if (reg->hr_task)
|
||||
pid = reg->hr_task->pid;
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
|
||||
if (!pid)
|
||||
return 0;
|
||||
|
||||
return sprintf(page, "%u\n", reg->hr_task->pid);
|
||||
return sprintf(page, "%u\n", pid);
|
||||
}
|
||||
|
||||
struct o2hb_region_attribute {
|
||||
@ -1495,13 +1511,17 @@ out:
|
||||
static void o2hb_heartbeat_group_drop_item(struct config_group *group,
|
||||
struct config_item *item)
|
||||
{
|
||||
struct task_struct *hb_task;
|
||||
struct o2hb_region *reg = to_o2hb_region(item);
|
||||
|
||||
/* stop the thread when the user removes the region dir */
|
||||
if (reg->hr_task) {
|
||||
kthread_stop(reg->hr_task);
|
||||
spin_lock(&o2hb_live_lock);
|
||||
hb_task = reg->hr_task;
|
||||
reg->hr_task = NULL;
|
||||
}
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
|
||||
if (hb_task)
|
||||
kthread_stop(hb_task);
|
||||
|
||||
config_item_put(item);
|
||||
}
|
||||
@ -1682,7 +1702,7 @@ out:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(o2hb_register_callback);
|
||||
|
||||
int o2hb_unregister_callback(struct o2hb_callback_func *hc)
|
||||
void o2hb_unregister_callback(struct o2hb_callback_func *hc)
|
||||
{
|
||||
BUG_ON(hc->hc_magic != O2HB_CB_MAGIC);
|
||||
|
||||
@ -1690,15 +1710,13 @@ int o2hb_unregister_callback(struct o2hb_callback_func *hc)
|
||||
__builtin_return_address(0), hc);
|
||||
|
||||
if (list_empty(&hc->hc_item))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
down_write(&o2hb_callback_sem);
|
||||
|
||||
list_del_init(&hc->hc_item);
|
||||
|
||||
up_write(&o2hb_callback_sem);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(o2hb_unregister_callback);
|
||||
|
||||
|
@ -70,7 +70,7 @@ void o2hb_setup_callback(struct o2hb_callback_func *hc,
|
||||
void *data,
|
||||
int priority);
|
||||
int o2hb_register_callback(struct o2hb_callback_func *hc);
|
||||
int o2hb_unregister_callback(struct o2hb_callback_func *hc);
|
||||
void o2hb_unregister_callback(struct o2hb_callback_func *hc);
|
||||
void o2hb_fill_node_map(unsigned long *map,
|
||||
unsigned bytes);
|
||||
void o2hb_init(void);
|
||||
|
@ -1638,17 +1638,8 @@ static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num,
|
||||
|
||||
void o2net_unregister_hb_callbacks(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = o2hb_unregister_callback(&o2net_hb_up);
|
||||
if (ret < 0)
|
||||
mlog(ML_ERROR, "Status return %d unregistering heartbeat up "
|
||||
"callback!\n", ret);
|
||||
|
||||
ret = o2hb_unregister_callback(&o2net_hb_down);
|
||||
if (ret < 0)
|
||||
mlog(ML_ERROR, "Status return %d unregistering heartbeat down "
|
||||
"callback!\n", ret);
|
||||
o2hb_unregister_callback(&o2net_hb_up);
|
||||
o2hb_unregister_callback(&o2net_hb_down);
|
||||
}
|
||||
|
||||
int o2net_register_hb_callbacks(void)
|
||||
|
@ -2730,14 +2730,17 @@ int dlm_empty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res)
|
||||
int ret;
|
||||
int lock_dropped = 0;
|
||||
|
||||
spin_lock(&res->spinlock);
|
||||
if (res->owner != dlm->node_num) {
|
||||
if (!__dlm_lockres_unused(res)) {
|
||||
mlog(ML_ERROR, "%s:%.*s: this node is not master, "
|
||||
"trying to free this but locks remain\n",
|
||||
dlm->name, res->lockname.len, res->lockname.name);
|
||||
}
|
||||
spin_unlock(&res->spinlock);
|
||||
goto leave;
|
||||
}
|
||||
spin_unlock(&res->spinlock);
|
||||
|
||||
/* Wheee! Migrate lockres here! Will sleep so drop spinlock. */
|
||||
spin_unlock(&dlm->spinlock);
|
||||
|
@ -265,8 +265,10 @@ static void dlm_run_purge_list(struct dlm_ctxt *dlm,
|
||||
/* This may drop and reacquire the dlm spinlock if it
|
||||
* has to do migration. */
|
||||
mlog(0, "calling dlm_purge_lockres!\n");
|
||||
dlm_lockres_get(lockres);
|
||||
if (dlm_purge_lockres(dlm, lockres))
|
||||
BUG();
|
||||
dlm_lockres_put(lockres);
|
||||
mlog(0, "DONE calling dlm_purge_lockres!\n");
|
||||
|
||||
/* Avoid adding any scheduling latencies */
|
||||
|
@ -164,8 +164,10 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb)
|
||||
}
|
||||
|
||||
status = o2hb_register_callback(&osb->osb_hb_up);
|
||||
if (status < 0)
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
o2hb_unregister_callback(&osb->osb_hb_down);
|
||||
}
|
||||
|
||||
bail:
|
||||
return status;
|
||||
@ -173,18 +175,11 @@ bail:
|
||||
|
||||
void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (ocfs2_mount_local(osb))
|
||||
return;
|
||||
|
||||
status = o2hb_unregister_callback(&osb->osb_hb_down);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
|
||||
status = o2hb_unregister_callback(&osb->osb_hb_up);
|
||||
if (status < 0)
|
||||
mlog_errno(status);
|
||||
o2hb_unregister_callback(&osb->osb_hb_down);
|
||||
o2hb_unregister_callback(&osb->osb_hb_up);
|
||||
}
|
||||
|
||||
void ocfs2_stop_heartbeat(struct ocfs2_super *osb)
|
||||
|
Loading…
Reference in New Issue
Block a user