Skip to content

Commit

Permalink
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/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()
  • Loading branch information
Linus Torvalds committed Mar 14, 2007
2 parents 0bdd0f3 + b36c3f8 commit 4e337ad
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 54 deletions.
27 changes: 12 additions & 15 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,25 +1141,22 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)

err = -ENOMEM;
dentry = d_alloc(configfs_sb->s_root, &name);
if (!dentry)
goto out_release;

d_add(dentry, NULL);
if (dentry) {
d_add(dentry, NULL);

err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
if (!err)
dentry = NULL;
else
d_delete(dentry);
err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
if (err) {
d_delete(dentry);
dput(dentry);
}
}

mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);

if (dentry) {
dput(dentry);
out_release:
unlink_group(group);
configfs_release_fs();
if (err) {
unlink_group(group);
configfs_release_fs();
}

return err;
Expand Down
26 changes: 25 additions & 1 deletion fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
50 changes: 34 additions & 16 deletions fs/ocfs2/cluster/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1319,20 +1320,28 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
*/
atomic_set(&reg->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1);

reg->hr_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);
hb_task = kthread_run(o2hb_thread, reg, "o2hb-%s",
reg->hr_item.ci_name);
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(&reg->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;
}

Expand All @@ -1354,10 +1363,17 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
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 {
Expand Down Expand Up @@ -1495,13 +1511,17 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
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);
reg->hr_task = NULL;
}
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);
}
Expand Down Expand Up @@ -1682,23 +1702,21 @@ int o2hb_register_callback(struct o2hb_callback_func *hc)
}
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);

mlog(ML_HEARTBEAT, "on behalf of %p for funcs %p\n",
__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);

Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/cluster/heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 2 additions & 11 deletions fs/ocfs2/cluster/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions fs/ocfs2/dlm/dlmmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions fs/ocfs2/dlm/dlmthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
15 changes: 5 additions & 10 deletions fs/ocfs2/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,22 @@ 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;
}

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)
Expand Down

0 comments on commit 4e337ad

Please sign in to comment.