[Ocfs2-commits] mfasheh commits r801 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Mar 19 19:32:59 CST 2004
Author: mfasheh
Date: 2004-03-19 19:32:58 -0600 (Fri, 19 Mar 2004)
New Revision: 801
Modified:
trunk/src/alloc.c
trunk/src/dcache.c
trunk/src/file.c
trunk/src/inc/ocfs.h
trunk/src/inc/proto.h
trunk/src/inode.c
trunk/src/journal.c
trunk/src/namei.c
trunk/src/oin.c
Log:
* get rid of oin->file_disk_off
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/alloc.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -2485,6 +2485,8 @@
}
}
+ OCFS_ASSERT (inode);
+
remainingLength = sectors;
localVbo = Vbo;
@@ -2492,7 +2494,7 @@
/* Thus we have to go to the disk, and update the Map */
/* Read the file Entry corresponding to this */
- status = ocfs_read_bh(osb, oin->file_disk_off, &fe_bh, OCFS_BH_COND_CACHED, inode);
+ status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &fe_bh, OCFS_BH_COND_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto finally;
Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/dcache.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -76,13 +76,16 @@
goto bail;
}
+ if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
+ goto bail;
+
/* check for oin */
if (inode_data_is_oin (inode)) {
ocfs_lock_res *res = NULL;
ret = 1; /* with an oin we cannot fail revalidate */
oin = GET_INODE_OIN(inode);
- if (ocfs_lookup_sector_node (osb, oin->file_disk_off, &res)==0) {
+ if (ocfs_lookup_sector_node (osb, GET_INODE_FEOFF(inode), &res)==0) {
/* if I hold cache lock, no revalidate needed */
if (res->lock_type == OCFS_DLM_ENABLE_CACHE_LOCK &&
res->master_node_num == osb->node_num) {
@@ -104,10 +107,6 @@
goto bail;
}
- /* shouldn't be revalidating root dir */
- if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
- goto bail;
-
off = GET_INODE_FEOFF(inode);
if (!off) {
/* icky failure case */
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/file.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -757,7 +757,7 @@
HI (oin->alloc_size), LO (oin->alloc_size), HI (newsize),
LO (newsize));
- status = ocfs_extend_file (osb, oin->parent_dirnode_off, oin, newsize, &oin->file_disk_off, NULL, inode, NULL);
+ status = ocfs_extend_file (osb, oin->parent_dirnode_off, oin, newsize, GET_INODE_FEOFF(inode), NULL, inode, NULL);
if (status < 0) {
if (status != -EINTR && status != -ENOSPC) {
LOG_ERROR_STATUS (status);
@@ -1085,7 +1085,7 @@
/* ocfs_extend_file()
*
*/
-int ocfs_extend_file (ocfs_super * osb, __u64 parent_off, ocfs_inode * oin, __u64 file_size, __u64 * file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr)
+int ocfs_extend_file (ocfs_super * osb, __u64 parent_off, ocfs_inode * oin, __u64 file_size, __u64 file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr)
{
int status = 0;
int tmpstat;
@@ -1115,7 +1115,7 @@
if (file_size == 0)
goto leave;
- status = ocfs_read_bh (osb, *file_off, &bh, OCFS_BH_CACHED, inode);
+ status = ocfs_read_bh (osb, file_off, &bh, OCFS_BH_CACHED, inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -1126,7 +1126,7 @@
if (!IS_VALID_FILE_ENTRY(fileEntry)) {
printk("fe->signature=%8s\n", fileEntry->signature);
printk("fe->filename=%8s\n", fileEntry->filename);
- LOG_ERROR_ARGS ("Invalid fe at offset %u.%u", HILO (*file_off));
+ LOG_ERROR_ARGS ("Invalid fe at offset %u.%u", HILO (file_off));
status = -EFAIL;
OCFS_BH_PUT_DATA(bh);
goto leave;
@@ -1427,7 +1427,7 @@
oin, inode);
else {
status = ocfs_extend_file(osb, parentOff, oin, newsize,
- &fileOff, NULL, inode, attr);
+ fileOff, NULL, inode, attr);
extended = true;
}
if (status < 0) {
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/inc/ocfs.h 2004-03-20 01:32:58 UTC (rev 801)
@@ -231,12 +231,20 @@
struct _ocfs_inode;
+/* OCFS2 Inode Private Data
+ *
+ * feoff/voteoff can change during rename. Luckily, rename takes a ton
+ * 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 oin->main_res
+ * 3) oin->open_hndl_cnt > 0
+ */
typedef struct _ocfs_inode_private
{
struct _ocfs_inode *oin;
__u64 voteoff;
__u64 feoff;
-// struct list_head i_clean_buffers;
atomic_t i_clean_buffer_seq;
__u8 deleted; /* this can be a generic flags field later */
} ocfs_inode_private;
@@ -1850,7 +1858,6 @@
ocfs_lock_res *lock_res;
ocfs_extent_map map;
__s64 alloc_size;
- __u64 file_disk_off; /* file location on the volume */
__u64 chng_seq_num;
__u64 parent_dirnode_off; /* from the start of vol */
__u32 open_hndl_cnt;
Modified: trunk/src/inc/proto.h
===================================================================
--- trunk/src/inc/proto.h 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/inc/proto.h 2004-03-20 01:32:58 UTC (rev 801)
@@ -80,7 +80,7 @@
int ocfs_sync_file (struct file *file, struct dentry *dentry, int datasync);
ssize_t ocfs_file_write (struct file *filp, const char *buf, size_t count, loff_t * ppos);
ssize_t ocfs_file_read (struct file *filp, char *buf, size_t count, loff_t * ppos);
-int ocfs_extend_file (ocfs_super * osb, __u64 parent_off, ocfs_inode * oin, __u64 file_size, __u64 * file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr);
+int ocfs_extend_file (ocfs_super * osb, __u64 parent_off, ocfs_inode * oin, __u64 file_size, __u64 file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr);
int ocfs_setattr (struct dentry *dentry, struct iattr *attr);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
int ocfs_getattr (struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/inode.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -895,7 +895,7 @@
if (unlock)
ocfs_up_sem (&(oin->main_res));
- status = ocfs_extend_file (osb, oin->parent_dirnode_off, oin, newsize, &oin->file_disk_off, NULL, inode, NULL);
+ status = ocfs_extend_file (osb, oin->parent_dirnode_off, oin, newsize, GET_INODE_FEOFF(inode), NULL, inode, NULL);
if (unlock)
ocfs_down_sem (&(oin->main_res), true);
@@ -1031,7 +1031,7 @@
len = 1;
down(&oin->extend_sem);
err = ocfs_lookup_file_allocation(osb, oin, vbo, &lbo, len, NULL,
- (oin->journal_inode) ? NULL : inode);
+ inode);
up(&oin->extend_sem);
if (err < 0) {
LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u", HILO(vbo),
@@ -1045,8 +1045,9 @@
if (bh_result->b_blocknr == 0) {
err = -EIO;
- LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u, fe=0x%08x",
- HILO(vbo), HILO(lbo), len, oin->file_disk_off);
+ LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u, feoff=(%u.%u)\n",
+ HILO(vbo), HILO(lbo), len,
+ HILO(GET_INODE_FEOFF(inode)));
}
bail:
@@ -1111,7 +1112,7 @@
vbo = (__s64) block << inode->i_sb->s_blocksize_bits;
len = 1;
err = ocfs_lookup_file_allocation(osb, oin, vbo, &lbo, len,
- NULL, NULL);
+ NULL, inode);
if (err < 0) {
LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u", HILO(vbo),
HILO(lbo), len);
@@ -1164,8 +1165,9 @@
*oblock = lbo >> inode->i_sb->s_blocksize_bits;
if (*oblock == 0) {
err = -EIO;
- LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u, fe=0x%08x",
- HILO(vbo), HILO(lbo), len, oin->file_disk_off);
+ LOG_ERROR_ARGS ("vbo=%u.%u lbo=%u.%u len=%u, feoff=(%u.%u)\n",
+ HILO(vbo), HILO(lbo), len,
+ HILO(GET_INODE_FEOFF(inode)));
}
bail:
Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/journal.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -35,7 +35,7 @@
static int ocfs_reset_publish (ocfs_super * osb, __u64 node_num);
static int ocfs_journal_release_locks(ocfs_journal_handle *handle, int abort);
static int ocfs_force_read_journal(ocfs_super *osb, __u64 size,
- ocfs_inode *oin);
+ ocfs_inode *oin, struct inode *inode);
static int ocfs_recover_vol(struct _ocfs_super *osb, int node_num);
static int __ocfs_recovery_thread(void *arg);
#ifdef USE_JOURNAL_CREATE_REPLACEMENT
@@ -1303,7 +1303,7 @@
* size should be file_size, NOT alloc_size
*/
static int ocfs_force_read_journal(ocfs_super *osb, __u64 size,
- ocfs_inode *oin)
+ ocfs_inode *oin, struct inode *inode)
{
int status = 0;
int i, run;
@@ -1334,7 +1334,7 @@
LOG_TRACE_ARGS("Force reading %u blocks\n", totalblks);
status = ocfs_lookup_file_allocation(osb, oin, vbo, &lbo, size, NULL,
- NULL);
+ inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto bail;
@@ -1583,7 +1583,7 @@
oin->journal_inode = true;
SET_INODE_OIN(inode, oin);
- status = ocfs_force_read_journal(osb, inode->i_size, oin);
+ status = ocfs_force_read_journal(osb, inode->i_size, oin, inode);
if (status < 0) {
LOG_ERROR_STATUS(status);
goto done;
Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/namei.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -1182,10 +1182,17 @@
tmpoff = tmpfe->this_sector;
down(&old_inode->i_sem);
+ /* we take oin->main_res because we want to lock out
+ * verify_update_oin, which reads fe_off from the
+ * inode, but doesn't always have i_sem. */
+ if (oldOIN)
+ ocfs_down_sem(&oldOIN->main_res, true);
status = ocfs_insert_file(osb, tmpfe, new_dir_bh, &insert_bh,
handle, old_dir, old_inode);
if (status < 0) {
+ if (oldOIN)
+ ocfs_up_sem(&oldOIN->main_res);
up(&old_inode->i_sem);
LOG_ERROR_STATUS (status);
goto finally;
@@ -1194,6 +1201,8 @@
status = ocfs_fix_extent_pointers(osb, handle, insert_bh,
old_inode);
if (status < 0) {
+ if (oldOIN)
+ ocfs_up_sem(&oldOIN->main_res);
up(&old_inode->i_sem);
LOG_ERROR_STATUS (status);
goto finally;
@@ -1201,9 +1210,6 @@
LOG_TRACE_ARGS("(after) tmpfe->this_sector = %u.%u\n",
HILO(tmpfe->this_sector));
- if (oldOIN)
- ocfs_down_sem(&oldOIN->main_res, true);
-
/* move the inode offset over to the new entry */
SET_INODE_FEOFF(old_dentry->d_inode, tmpfe->this_sector);
if (S_ISDIR(old_dentry->d_inode->i_mode)) {
@@ -1221,10 +1227,8 @@
tmpfe->this_sector,
tmpfe->this_sector);
}
- if (oldOIN) {
- oldOIN->file_disk_off = tmpfe->this_sector;
+ if (oldOIN)
ocfs_up_sem(&oldOIN->main_res);
- }
up(&old_inode->i_sem);
} else {
/* Ok, we're moving inside of the same directory --
@@ -1416,7 +1420,7 @@
OCFS_BH_PUT_DATA(new_fe_bh);
fe = NULL;
- status = ocfs_extend_file (osb, parent_off, NULL, newsize, &file_off, handle, inode, NULL);
+ status = ocfs_extend_file (osb, parent_off, NULL, newsize, file_off, handle, inode, NULL);
if (status < 0) {
if (status != -ENOSPC && status != -EINTR) {
LOG_ERROR_ARGS ("Failed to extend file to %u.%u", HILO (newsize));
Modified: trunk/src/oin.c
===================================================================
--- trunk/src/oin.c 2004-03-20 01:27:58 UTC (rev 800)
+++ trunk/src/oin.c 2004-03-20 01:32:58 UTC (rev 801)
@@ -47,6 +47,7 @@
struct list_head *iter;
struct list_head *temp_iter;
int disk_len;
+ __u64 offset;
ocfs_disk_lock dlock; /* ???: is this too much on the stack? */
/* We are setting the oin Updated flag in the end. */
@@ -54,9 +55,19 @@
OCFS_ASSERT (oin);
+ if (!oin->inode) {
+ printk(KERN_ERR "ocfs2: oin has no inode!\n");
+ BUG();
+ }
+
*needs_trunc = 0;
- status = ocfs_read_bh(osb, oin->file_disk_off, &fe_bh, OCFS_BH_COND_CACHED, oin->inode);
+ /* This read of feoff from the inode depends on all callers to
+ * make sure that unlink or rename can't be change it while we're
+ * in here! */
+ offset = GET_INODE_FEOFF(oin->inode);
+
+ status = ocfs_read_bh(osb, offset, &fe_bh, OCFS_BH_COND_CACHED, oin->inode);
if (status < 0) {
LOG_ERROR_STATUS (status);
goto leave;
@@ -459,7 +470,6 @@
oin->osb = osb;
oin->oin_flags |= flags;
oin->open_hndl_cnt = 0;
- oin->file_disk_off = file_off;
oin->journal_inode = false;
ocfs_extent_map_init (&oin->map);
@@ -709,8 +719,8 @@
struct inode *inode;
int refcount = 0;
int status = 0;
+ __u64 feoff = 0;
-
LOG_ENTRY_ARGS ("(oin = 0x%08x)\n", oin);
if (oin == NULL)
@@ -725,6 +735,7 @@
dentry = list_entry (iter, struct dentry, d_alias);
refcount += atomic_read(&dentry->d_count);
}
+ feoff = GET_INODE_FEOFF(inode);
}
@@ -745,9 +756,8 @@
lockResource = (ocfs_lock_res *) oin->lock_res;
if (lockResource == NULL) {
- LOG_ERROR_ARGS("lockres=null, oin->file_disk_off "
- "= %u.%u\n",
- HILO(oin->file_disk_off));
+ LOG_ERROR_ARGS("lockres=null, feoff = %u.%u\n",
+ HILO(feoff));
goto bail;
}
More information about the Ocfs2-commits
mailing list