[Ocfs2-commits] mfasheh commits r883 - in trunk: . src src/inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Apr 29 14:52:14 CDT 2004
Author: mfasheh
Date: 2004-04-29 13:52:12 -0500 (Thu, 29 Apr 2004)
New Revision: 883
Removed:
trunk/src/sem.c
Modified:
trunk/TODO
trunk/src/Makefile
trunk/src/dcache.c
trunk/src/file.c
trunk/src/inc/ocfs.h
trunk/src/inc/proto.h
trunk/src/inode.c
trunk/src/namei.c
trunk/src/nm.c
trunk/src/oin.c
Log:
* Get rid of main_res, the last of the ocfs_sems. It has been replaced with
priv_sem, a struct semaphore.
* Demolish the ocfs_sem infrastructure. If anyone ever suggests we do
recursive semaphores in the kernel...
* Get rid of ocfs_extend_allocation which was basically a do-nothing
function. Replace it with direct calls to ocfs_extend_file instead.
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/TODO 2004-04-29 18:52:12 UTC (rev 883)
@@ -17,10 +17,6 @@
* get rid of osb->curr_trans_id as it was never used (always zero)
-* turn as many ocfs_sem's into normal struct semaphores as possible.
- Potentially trivial ones include: dir_alloc_lock, file_alloc_lock,
- and hashlock
-
* get rid of all the:
changeSeqNum = osb->curr_trans_id;
DISK_LOCK_SEQNUM(fe) = changeSeqNum;
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/Makefile 2004-04-29 18:52:12 UTC (rev 883)
@@ -153,7 +153,6 @@
oin.c \
osb.c \
proc.c \
- sem.c \
super.c \
symlink.c \
sysfile.c \
Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/dcache.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -97,12 +97,12 @@
/* hit the disk */
/* TODO: optimize */
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = true;
tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/file.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -95,7 +95,6 @@
ocfs_super *osb = NULL;
bool bAcquiredOIN = false;
struct buffer_head *fe_bh = NULL;
- ocfs_sem *oin_sem = NULL;
int truncate_pages = 0;
LOG_ENTRY_ARGS ("(0x%08x, 0x%08x, '%*s')\n", inode, file,
@@ -112,8 +111,7 @@
/* kch - for an open request we are already given the
* inode, and therefore we are given the oin too */
down(&inode->i_sem);
- oin_sem = &(OCFS_I(inode)->main_res);
- ocfs_down_sem (oin_sem, true);
+ down (&(OCFS_I(inode)->priv_sem));
bAcquiredOIN = true;
/* If the in use flag is set, forget about it. This will go
@@ -156,7 +154,7 @@
}
}
up(&inode->i_sem);
- /* yes, hold onto main_res. */
+ /* yes, hold onto priv_sem. */
if (OCFS_I(inode)->oin_flags & OCFS_OIN_DELETE_ON_CLOSE) {
LOG_TRACE_STR ("oin has DELETE_ON_CLOSE set, returning DELETE_PENDING");
@@ -213,7 +211,7 @@
OCFS_I(inode)->open_hndl_cnt++;
if (bAcquiredOIN) {
- ocfs_up_sem (oin_sem);
+ up (&(OCFS_I(inode)->priv_sem));
bAcquiredOIN = false;
}
@@ -230,8 +228,8 @@
status = 0;
leave:
- if (bAcquiredOIN && oin_sem) {
- ocfs_up_sem (oin_sem);
+ if (bAcquiredOIN) {
+ up (&(OCFS_I(inode)->priv_sem));
bAcquiredOIN = false;
}
@@ -304,13 +302,13 @@
goto bail;
}
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->open_hndl_cnt--;
if (!OCFS_I(inode)->open_hndl_cnt)
last_close = true;
if (inode->i_ino == OCFS_ROOT_INODE_NUMBER) {
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
goto bail;
}
@@ -326,7 +324,7 @@
OCFS_CLEAR_FLAG(OCFS_I(inode)->oin_flags, OCFS_OIN_OPEN_FOR_DIRECTIO);
if (OCFS_I(inode)->oin_flags & OCFS_OIN_NEEDS_DELETION) {
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
LOG_ERROR_STR("Not deleting lockrse on a last close! eek!");
goto bail;
}
@@ -354,7 +352,7 @@
spin_unlock(&oin_num_ext_lock);
up(&recovery_list_sem);
}
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
ocfs_sync_inode(inode);
if (last_close) {
@@ -627,9 +625,9 @@
if (OCFS_I(inode)->needs_verification) {
LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
if (status < 0) {
@@ -755,9 +753,9 @@
}
if (OCFS_I(inode)->needs_verification) {
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
if (status < 0) {
@@ -862,7 +860,7 @@
goto leave;
}
- ocfs_down_sem(&OCFS_I(inode)->main_res, true);
+ down(&OCFS_I(inode)->priv_sem);
fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
@@ -875,7 +873,7 @@
"to size (%u.%u)!\n", HILO(fe->file_size),
HILO(file_size));
OCFS_BH_PUT_DATA(bh);
- ocfs_up_sem(&OCFS_I(inode)->main_res);
+ up(&OCFS_I(inode)->priv_sem);
status = -EINVAL;
LOG_ERROR_STATUS(status);
goto leave;
@@ -887,7 +885,7 @@
status = ocfs_free_extents_for_truncate (osb, fe, handle, inode);
if (status < 0) {
OCFS_BH_PUT_DATA(bh);
- ocfs_up_sem(&OCFS_I(inode)->main_res);
+ up(&OCFS_I(inode)->priv_sem);
LOG_ERROR_STATUS (status);
goto leave;
}
@@ -907,14 +905,14 @@
status = ocfs_journal_dirty(handle, bh);
if (status < 0) {
- ocfs_up_sem(&OCFS_I(inode)->main_res);
+ up(&OCFS_I(inode)->priv_sem);
LOG_ERROR_STATUS (status);
goto leave;
}
/* if we updated correctly then we can update the alloc_size */
OCFS_I(inode)->alloc_size = new_alloc_size;
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
leave:
if (handle && (status == 0))
@@ -1122,9 +1120,9 @@
/* update the total allocation size here */
fileEntry->alloc_size += actualLength;
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->alloc_size = fileEntry->alloc_size;
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
/* no need to do OCFS_SECTOR_ALIGN once the allocation size is correct. */
DISK_LOCK_SEQNUM (fileEntry) = 0;
@@ -1269,19 +1267,19 @@
parentOff = GET_INODE_VOTEOFF(parentInode);
if (attr->ia_valid & ATTR_SIZE) {
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
if (OCFS_I(inode)->needs_verification) {
LOG_TRACE_STR ("OIN_NEEDS_VERIFICATION");
status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
if (status < 0) {
LOG_ERROR_STATUS (status);
LOG_TRACE_STR ("TODO: disable volume");
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
error = -EIO;
goto bail;
}
}
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
@@ -1300,13 +1298,13 @@
goto bail;
}
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
if (inode->i_size > newsize) {
ocfs_delete_all_extent_maps(osb, inode);
}
inode->i_size = newsize;
inode->i_blocks = (newsize + sb->s_blocksize) >> sb->s_blocksize_bits;
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
}
/* if directory, put FILE_ENTRY ptr into fileOff */
@@ -1404,9 +1402,9 @@
if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
goto bail;
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
status = ocfs_verify_update_inode (osb, inode, &needs_trunc);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc)
ocfs_truncate_inode_pages(inode, 0);
if (status < 0)
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/inc/ocfs.h 2004-04-29 18:52:12 UTC (rev 883)
@@ -492,9 +492,6 @@
#define OCFS_IP_MASK "subnet_mask"
#define OCFS_COMM_TYPE "type"
-#define OCFS_SEM_MAGIC 0xAFABFACE
-#define OCFS_SEM_DELETED 0x0D0D0D0D
-
#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGHUP) | \
sigmask(SIGINT) | sigmask(SIGQUIT))
@@ -1407,16 +1404,6 @@
struct _ocfs_clean_buffer_list *next;
};
-
-typedef struct _ocfs_sem
-{
- long magic; /* OCFS_SEM_MAGIC */
- pid_t pid;
- long count;
- struct semaphore sem;
-}
-ocfs_sem;
-
typedef struct _HASHBUCKET
{
__u32 keylen;
@@ -1712,7 +1699,7 @@
* of locks and does several checks, so you're safe reading these values
* if any of the following is true:
* 1) you have i_sem
- * 2) you have main_res
+ * 2) you have priv_sem
* 3) open_hndl_cnt > 0
*/
typedef struct _ocfs_inode_private
@@ -1723,8 +1710,8 @@
__u64 voteoff;
__u64 feoff;
- ocfs_sem main_res;
- /* These fields are protected by main_res */
+ /* These fields are protected by priv_sem */
+ struct semaphore priv_sem;
__u32 open_hndl_cnt;
bool needs_verification;
__u64 chng_seq_num;
Modified: trunk/src/inc/proto.h
===================================================================
--- trunk/src/inc/proto.h 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/inc/proto.h 2004-04-29 18:52:12 UTC (rev 883)
@@ -108,12 +108,6 @@
int ocfs_submit_vol_metadata(ocfs_super *osb, ocfs_offset_map *map_buf, __u32 num);
int ocfs_commit_thread(void *arg);
-void ocfs_init_sem (ocfs_sem * res);
-bool ocfs_down_sem (ocfs_sem * res, bool wait);
-void ocfs_up_sem (ocfs_sem * res);
-int ocfs_del_sem (ocfs_sem * res);
-
-
int ocfs_hash_create (HASHTABLE *ht, __u32 noofbits);
void ocfs_hash_destroy (HASHTABLE *ht, void (*freefn) (const void *p));
int ocfs_hash_del (HASHTABLE * ht, void *key, __u32 keylen);
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/inode.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -34,7 +34,6 @@
static int ocfs_prepare_write (struct file *file, struct page *page, unsigned from, unsigned to);
static int ocfs_commit_write (struct file *file, struct page *page, unsigned from, unsigned to);
static int ocfs_get_block (struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create);
-static int ocfs_extend_allocation(ocfs_super *osb, __u64 newsize, bool unlock, struct inode *inode);
static int ocfs_symlink_get_block (struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -348,7 +347,7 @@
i->flags = 0;
atomic_set(&i->i_clean_buffer_seq, 0);
- ocfs_init_sem (&(i->main_res));
+ init_MUTEX(&(i->priv_sem));
init_MUTEX(&(i->inode_extend_sem));
i->open_hndl_cnt = 0;
ocfs_extent_map_init (&i->map);
@@ -875,8 +874,6 @@
list_del(&OCFS_I(inode)->recovery_list);
up(&recovery_list_sem);
- ocfs_del_sem (&(OCFS_I(inode)->main_res));
-
/* clean out the inode private ... why?! */
memset(inode->u.generic_ip, 0, sizeof(ocfs_inode_private));
@@ -978,41 +975,7 @@
return err;
} /* ocfs_block_symlink */
-
/*
- * ocfs_extend_allocation()
- *
- */
-static inline int ocfs_extend_allocation(ocfs_super *osb, __u64 newsize, bool unlock, struct inode *inode)
-{
- int status = 0;
-
- if (newsize > OCFS_I(inode)->alloc_size) {
- LOG_TRACE_ARGS ("Extend: have=%u.%u, need=%u.%u\n",
- HILO (OCFS_I(inode)->alloc_size),
- HILO (newsize));
-
- if (unlock)
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
-
- status = ocfs_extend_file (osb, newsize,
- GET_INODE_FEOFF(inode), NULL,
- inode, NULL);
-
- if (unlock)
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
- }
-
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- LOG_TRACE_ARGS ("Failed to extend file to %u.%u\n", HILO (newsize));
- status = -ENOSPC;
- }
-
- return status;
-} /* ocfs_extend_allocation */
-
-/*
* ocfs_symlink_get_block()
*
*/
@@ -1106,15 +1069,16 @@
if (!INODE_JOURNAL(inode) && vbo >= OCFS_I(inode)->alloc_size) {
LOG_TRACE_STR("Extending allocation");
- err = ocfs_extend_allocation(osb, vbo+512, false, inode);
+ err = ocfs_extend_file(osb, vbo + 512ULL, GET_INODE_FEOFF(inode), NULL, inode, NULL);
if (err < 0) {
+ err = -ENOSPC;
LOG_ERROR_STATUS (err);
goto bail;
}
}
if (!(OCFS_I(inode)->oin_flags & OCFS_OIN_OPEN_FOR_DIRECTIO)) {
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down(&(OCFS_I(inode)->priv_sem));
oin_locked = true;
}
@@ -1144,7 +1108,7 @@
err = -EIO;
if (oin_locked && !(OCFS_I(inode)->oin_flags & OCFS_OIN_OPEN_FOR_DIRECTIO)) {
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up(&(OCFS_I(inode)->priv_sem));
}
LOG_EXIT_LONG (err);
@@ -1355,10 +1319,11 @@
/* NOTE: create flag is set when we ?may? have to allocate some
blocks for the file. */
if (create && vbo_max > OCFS_I(inode)->alloc_size) {
- /* WARNING: How much do we really want to extend the file?
- is 'false' the right argument there? */
- status = ocfs_extend_allocation(osb, vbo_max, false, inode);
+ /* WARNING: How much do we really want to extend the file? */
+ status = ocfs_extend_file(osb, vbo_max, GET_INODE_FEOFF(inode),
+ NULL, inode, NULL);
if (status < 0) {
+ status = -ENOSPC;
LOG_ERROR_STR("ocfs_direct_IO_get_blocks: failed to extend the file!");
goto bail;
}
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/namei.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -567,9 +567,9 @@
}
spin_unlock(&oin_num_ext_lock);
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_SET_FLAG (OCFS_I(inode)->oin_flags, OCFS_OIN_DELETE_ON_CLOSE);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
status = ocfs_fe_smash (osb, parentOff, 0, fileOff,
NULL, dentry, parentInode);
@@ -579,9 +579,9 @@
status != -EBUSY && status != -EINTR)
LOG_ERROR_STATUS(status);
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_CLEAR_FLAG (OCFS_I(inode)->oin_flags, OCFS_OIN_DELETE_ON_CLOSE);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
goto bail;
}
}
@@ -990,9 +990,9 @@
if (new_inode) {
if (!(OCFS_I(new_inode)->oin_flags & OCFS_OIN_DELETE_ON_CLOSE)) {
/* OIN exists and it's not marked for deletion! */
- ocfs_down_sem (&(OCFS_I(new_inode)->main_res), true);
+ down (&(OCFS_I(new_inode)->priv_sem));
status = ocfs_verify_update_inode (osb, new_inode, &needs_trunc);
- ocfs_up_sem (&(OCFS_I(new_inode)->main_res));
+ up (&(OCFS_I(new_inode)->priv_sem));
delete_target_oin = true;
if (needs_trunc)
ocfs_truncate_inode_pages(new_inode, 0);
@@ -1162,15 +1162,15 @@
tmpoff = tmpfe->this_sector;
down(&old_inode->i_sem);
- /* we take oin->main_res because we want to lock out
+ /* we take oin->priv_sem because we want to lock out
* verify_update_oin, which reads fe_off from the
* inode, but doesn't always have i_sem. */
- ocfs_down_sem(&OCFS_I(old_inode)->main_res, true);
+ down(&OCFS_I(old_inode)->priv_sem);
status = ocfs_insert_file(osb, tmpfe, new_dir_bh, &insert_bh,
handle, old_dir, old_inode);
if (status < 0) {
- ocfs_up_sem(&OCFS_I(old_inode)->main_res);
+ up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
LOG_ERROR_STATUS (status);
goto finally;
@@ -1179,7 +1179,7 @@
status = ocfs_fix_extent_pointers(osb, handle, insert_bh,
old_inode);
if (status < 0) {
- ocfs_up_sem(&OCFS_I(old_inode)->main_res);
+ up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
LOG_ERROR_STATUS (status);
goto finally;
@@ -1193,7 +1193,7 @@
tmpfe->this_sector,
oldfe_lockres);
if (status < 0) {
- ocfs_up_sem(&OCFS_I(old_inode)->main_res);
+ up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
LOG_ERROR_STATUS (status);
goto finally;
@@ -1215,7 +1215,7 @@
tmpfe->this_sector,
tmpfe->this_sector);
}
- ocfs_up_sem(&OCFS_I(old_inode)->main_res);
+ up(&OCFS_I(old_inode)->priv_sem);
up(&old_inode->i_sem);
} else {
/* Ok, we're moving inside of the same directory --
Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/nm.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -797,7 +797,7 @@
ocfs_vote *vote = NULL;
struct buffer_head *fe_bh = NULL, *vote_bh = NULL;
int vote_type = INVALID_REQUEST, vote_response = 0;
- ocfs_sem *oin_sem = NULL;
+ bool oin_sem = false;
struct inode *inode = NULL;
bool master_alive = true, is_dir = false;
bool is_locked, open_handle;
@@ -926,12 +926,12 @@
switch (vote_type) {
case UPDATE_OIN_INODE:
LOG_TRACE_STR("UPDATE_OIN_INODE");
- ocfs_down_sem (&(OCFS_I(inode)->main_res), true);
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = true;
tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
if (tmpstat < 0)
LOG_ERROR_STATUS (tmpstat);
- ocfs_up_sem (&(OCFS_I(inode)->main_res));
+ up (&(OCFS_I(inode)->priv_sem));
if (needs_trunc) {
if (inode)
ocfs_truncate_inode_pages(inode, 0);
@@ -948,8 +948,8 @@
vote_response = FLAG_VOTE_NODE;
if (inode) {
- oin_sem = &(OCFS_I(inode)->main_res);
- ocfs_down_sem (oin_sem, true);
+ oin_sem = true;
+ down (&(OCFS_I(inode)->priv_sem));
OCFS_I(inode)->needs_verification = true;
tmpstat = ocfs_verify_update_inode(osb, inode, &needs_trunc);
if (tmpstat < 0)
@@ -969,11 +969,11 @@
vote_response = FLAG_VOTE_OIN_ALREADY_INUSE;
} else {
OCFS_SET_FLAG (OCFS_I(inode)->oin_flags, OCFS_OIN_NEEDS_DELETION);
- ocfs_up_sem (oin_sem);
+ up(&(OCFS_I(inode)->priv_sem));
ocfs_release_lockres (lockres);
ocfs_put_lockres(lockres);
lockres = NULL;
- oin_sem = NULL;
+ oin_sem = false;
if (needs_trunc) {
ocfs_truncate_inode_pages(inode, 0);
needs_trunc = 0;
@@ -1043,8 +1043,10 @@
brelse(fe_bh);
}
}
- if (oin_sem)
- ocfs_up_sem (oin_sem);
+ if (oin_sem) {
+ up(&(OCFS_I(inode)->priv_sem));
+ oin_sem = false;
+ }
if (needs_trunc) {
ocfs_truncate_inode_pages(inode, 0);
@@ -1302,7 +1304,7 @@
"extend" : "truncate", flags & FLAG_RELEASE_LOCK ?
"release" : "acquire", inode, node_num);
- ocfs_down_sem(&OCFS_I(inode)->main_res, true);
+ down(&OCFS_I(inode)->priv_sem);
if (OCFS_I(inode)->open_hndl_cnt
&& (flags & FLAG_ACQUIRE_LOCK)) {
spin_lock(&oin_num_ext_lock);
@@ -1352,7 +1354,7 @@
up(&recovery_list_sem);
}
- ocfs_up_sem(&OCFS_I(inode)->main_res);
+ up(&OCFS_I(inode)->priv_sem);
}
if (disk_vote) {
Modified: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/oin.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -254,7 +254,7 @@
return status;
} /* ocfs_verify_update_inode */
-/* you should be holding i_sem and main_res in this function.
+/* you should be holding i_sem and priv_sem in this function.
*
* Put a lockres on the oin and if needed add ourselves to the open
* map. Only call this on 1st open of a file. Marks the oin as "in use"
Deleted: trunk/src/sem.c
===================================================================
--- trunk/src/sem.c 2004-04-28 23:24:33 UTC (rev 882)
+++ trunk/src/sem.c 2004-04-29 18:52:12 UTC (rev 883)
@@ -1,143 +0,0 @@
-/*
- * sem.c
- *
- * Init, del, down and up recursive lock, ocfs_sem
- *
- * Copyright (C) 2002, 2004 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- * Manish Singh
- */
-
-#include "inc/ocfs.h"
-
-#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_SEM
-
-/*
- * ocfs_init_sem()
- *
- */
-void ocfs_init_sem (ocfs_sem * res)
-{
- LOG_ENTRY ();
-
- memset (res, 0, sizeof (ocfs_sem));
- init_MUTEX (&(res->sem));
- res->magic = OCFS_SEM_MAGIC;
-
- LOG_EXIT ();
-} /* ocfs_init_sem */
-
-/*
- * ocfs_down_sem()
- *
- * Counter layer atop the sem. If a process which already owns the sem,
- * attempts to re-acquire it, ocfs_down_sem() increments the
- * count by 1. If however, a different process attempts to acquire that
- * sem, it blocks waiting for the sem to be released.
- * ocfs_up_sem() decrements the count by 1, if the owning
- * process releases the sem. The sem is released when the counter hits 0.
- * NT Port leftover, we want to get rid of this as soon as possible
- */
-bool ocfs_down_sem (ocfs_sem * res, bool wait)
-{
- bool ret = true;
-
- LOG_ENTRY ();
-
- if (res->magic != OCFS_SEM_MAGIC) {
- LOG_ERROR_ARGS("semaphore magic value is bad!\n");
-
- BUG();
- }
-
- if (res->pid == 0) {
- if (wait) {
- down(&(res->sem));
- res->pid = current->pid;
- res->count = 1;
- } else {
- if (!down_trylock(&(res->sem))) {
- res->pid = current->pid;
- res->count = 1;
- }
- else
- ret = false;
- }
- } else {
- if (res->pid == current->pid)
- res->count++;
- else {
- if (wait) {
- down(&(res->sem));
- res->pid = current->pid;
- res->count = 1;
- } else
- ret = false;
- }
- }
-
- LOG_EXIT_ULONG (ret);
- return ret;
-} /* ocfs_down_sem */
-
-/*
- * ocfs_up_sem()
- *
- * ocfs_up_sem() decrements the count by 1, if the owning
- * process releases the sem. The sem is released when the counter hits 0.
- * Remained of NT port, we really really do not want this nesting
- * but for now it's there, we'll clean it up
- */
-void ocfs_up_sem (ocfs_sem * res)
-{
- LOG_ENTRY ();
-
- if (res->magic != OCFS_SEM_MAGIC) {
- LOG_ERROR_ARGS("semaphore magic value is bad!\n");
-
- BUG();
- }
-
- if (res->count && current->pid == res->pid) {
- res->count--;
- if (!res->count) {
- res->pid = 0;
- up (&(res->sem));
- }
- }
-
- LOG_EXIT ();
- return;
-} /* ocfs_up_sem */
-
-/*
- * ocfs_del_sem()
- *
- */
-int ocfs_del_sem (ocfs_sem * res)
-{
- LOG_ENTRY ();
-
- res->magic = OCFS_SEM_DELETED;
-
- LOG_EXIT ();
- return 0;
-} /* ocfs_del_sem */
-
-
More information about the Ocfs2-commits
mailing list