/* Ok. By now we've either got the offsets passed to us by the * caller, or we just pulled them off the bh. Lets do some
* sanity checks to make sure they're OK. */ if (blkno == 0) {
inode = ERR_PTR(-EINVAL);
mlog_errno(PTR_ERR(inode)); goto bail;
}
inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor,
ocfs2_init_locked_inode, &args); /* inode was *not* in the inode cache. 2.6.x requires * us to do our own read_inode call and unlock it
* afterwards. */ if (inode == NULL) {
inode = ERR_PTR(-ENOMEM);
mlog_errno(PTR_ERR(inode)); goto bail;
}
trace_ocfs2_iget5_locked(inode->i_state); if (inode->i_state & I_NEW) {
rc = ocfs2_read_locked_inode(inode, &args);
unlock_new_inode(inode);
} if (is_bad_inode(inode)) {
iput(inode);
inode = ERR_PTR(rc); goto bail;
}
/* * Set transaction id's of transactions that have to be committed * to finish f[data]sync. We set them to currently running transaction * as we cannot be sure that the inode or some of its metadata isn't * part of the transaction - the inode could have been reclaimed and * now it is reread from disk.
*/ if (journal) {
transaction_t *transaction;
tid_t tid; struct ocfs2_inode_info *oi = OCFS2_I(inode);
read_lock(&journal->j_state_lock); if (journal->j_running_transaction)
transaction = journal->j_running_transaction; else
transaction = journal->j_committing_transaction; if (transaction)
tid = transaction->t_tid; else
tid = journal->j_commit_sequence;
read_unlock(&journal->j_state_lock);
oi->i_sync_tid = tid;
oi->i_datasync_tid = tid;
}
bail: if (!IS_ERR(inode)) {
trace_ocfs2_iget_end(inode,
(unsignedlonglong)OCFS2_I(inode)->ip_blkno);
}
return inode;
}
staticint ocfs2_dinode_has_extents(struct ocfs2_dinode *di)
{ /* inodes flagged with other stuff in id2 */ if (di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
OCFS2_CHAIN_FL | OCFS2_DEALLOC_FL)) return 0; /* i_flags doesn't indicate when id2 is a fast symlink */ if (S_ISLNK(di->i_mode) && di->i_size && di->i_clusters == 0) return 0; if (di->i_dyn_features & OCFS2_INLINE_DATA_FL) return 0;
return 1;
}
/* * here's how inodes get read from disk: * iget5_locked -> find_actor -> OCFS2_FIND_ACTOR * found? : return the in-memory inode * not found? : get_new_inode -> OCFS2_INIT_LOCKED_INODE
*/
/* * initialize the new inode, but don't do anything that would cause * us to sleep. * return 0 on success, 1 on failure
*/ staticint ocfs2_init_locked_inode(struct inode *inode, void *opaque)
{ struct ocfs2_find_inode_args *args = opaque; #ifdef CONFIG_LOCKDEP staticstruct lock_class_key ocfs2_sysfile_lock_key[NUM_SYSTEM_INODES]; staticstruct lock_class_key ocfs2_quota_ip_alloc_sem_key,
ocfs2_file_ip_alloc_sem_key; #endif
inode->i_ino = args->fi_ino;
OCFS2_I(inode)->ip_blkno = args->fi_blkno; #ifdef CONFIG_LOCKDEP switch (args->fi_sysfile_type) { case BAD_BLOCK_SYSTEM_INODE: break; case GLOBAL_INODE_ALLOC_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[GLOBAL_INODE_ALLOC_SYSTEM_INODE]); break; case SLOT_MAP_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[SLOT_MAP_SYSTEM_INODE]); break; case HEARTBEAT_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[HEARTBEAT_SYSTEM_INODE]); break; case GLOBAL_BITMAP_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[GLOBAL_BITMAP_SYSTEM_INODE]); break; case USER_QUOTA_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[USER_QUOTA_SYSTEM_INODE]); break; case GROUP_QUOTA_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[GROUP_QUOTA_SYSTEM_INODE]); break; case ORPHAN_DIR_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[ORPHAN_DIR_SYSTEM_INODE]); break; case EXTENT_ALLOC_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[EXTENT_ALLOC_SYSTEM_INODE]); break; case INODE_ALLOC_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[INODE_ALLOC_SYSTEM_INODE]); break; case JOURNAL_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[JOURNAL_SYSTEM_INODE]); break; case LOCAL_ALLOC_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[LOCAL_ALLOC_SYSTEM_INODE]); break; case TRUNCATE_LOG_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[TRUNCATE_LOG_SYSTEM_INODE]); break; case LOCAL_USER_QUOTA_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[LOCAL_USER_QUOTA_SYSTEM_INODE]); break; case LOCAL_GROUP_QUOTA_SYSTEM_INODE:
lockdep_set_class(&inode->i_rwsem,
&ocfs2_sysfile_lock_key[LOCAL_GROUP_QUOTA_SYSTEM_INODE]); break; default:
WARN_ONCE(1, "Unknown sysfile type %d\n", args->fi_sysfile_type);
} if (args->fi_sysfile_type == USER_QUOTA_SYSTEM_INODE ||
args->fi_sysfile_type == GROUP_QUOTA_SYSTEM_INODE ||
args->fi_sysfile_type == LOCAL_USER_QUOTA_SYSTEM_INODE ||
args->fi_sysfile_type == LOCAL_GROUP_QUOTA_SYSTEM_INODE)
lockdep_set_class(&OCFS2_I(inode)->ip_alloc_sem,
&ocfs2_quota_ip_alloc_sem_key); else
lockdep_set_class(&OCFS2_I(inode)->ip_alloc_sem,
&ocfs2_file_ip_alloc_sem_key); #endif
return 0;
}
void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, int create_ino)
{ struct super_block *sb; struct ocfs2_super *osb; int use_plocks = 1;
/* * These have all been checked by ocfs2_read_inode_block() or set * by ocfs2_mknod_locked(), so a failure is a code bug.
*/
BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); /* This means that read_inode cannot create a superblock inode today. change if
that is needed. */
BUG_ON(!(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL)));
BUG_ON(le32_to_cpu(fe->i_fs_generation) != osb->fs_generation);
if (create_ino) {
inode->i_ino = ino_from_blkno(inode->i_sb,
le64_to_cpu(fe->i_blkno));
/* * If we ever want to create system files from kernel, * the generation argument to * ocfs2_inode_lock_res_init() will have to change.
*/
BUG_ON(le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL);
status = -EINVAL;
sb = inode->i_sb;
osb = OCFS2_SB(sb);
/* * To improve performance of cold-cache inode stats, we take * the cluster lock here if possible. * * Generally, OCFS2 never trusts the contents of an inode * unless it's holding a cluster lock, so taking it here isn't * a correctness issue as much as it is a performance * improvement. * * There are three times when taking the lock is not a good idea: * * 1) During startup, before we have initialized the DLM. * * 2) If we are reading certain system files which never get * cluster locks (local alloc, truncate log). * * 3) If the process doing the iget() is responsible for * orphan dir recovery. We're holding the orphan dir lock and * can get into a deadlock with another process on another * node in ->delete_inode(). * * #1 and #2 can be simply solved by never taking the lock * here for system files (which are the only type we read * during mount). It's a heavier approach, but our main * concern is user-accessible files anyway. * * #3 works itself out because we'll eventually take the * cluster lock before trusting anything anyway.
*/
can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE)
&& !(args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY)
&& !ocfs2_mount_local(osb);
/* * To maintain backwards compatibility with older versions of * ocfs2-tools, we still store the generation value for system * files. The only ones that actually matter to userspace are * the journals, but it's easier and inexpensive to just flag * all system files similarly.
*/ if (args->fi_flags & OCFS2_FI_FLAG_SYSFILE)
generation = osb->fs_generation;
if (can_lock) {
status = ocfs2_open_lock(inode); if (status) {
make_bad_inode(inode);
mlog_errno(status); return status;
}
status = ocfs2_inode_lock(inode, NULL, lock_level); if (status) {
make_bad_inode(inode);
mlog_errno(status); return status;
}
}
if (args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY) {
status = ocfs2_try_open_lock(inode, 0); if (status) {
make_bad_inode(inode); return status;
}
}
if (can_lock) { if (args->fi_flags & OCFS2_FI_FLAG_FILECHECK_CHK)
status = ocfs2_filecheck_read_inode_block_full(inode,
&bh, OCFS2_BH_IGNORE_CACHE, 0); elseif (args->fi_flags & OCFS2_FI_FLAG_FILECHECK_FIX)
status = ocfs2_filecheck_read_inode_block_full(inode,
&bh, OCFS2_BH_IGNORE_CACHE, 1); else
status = ocfs2_read_inode_block_full(inode,
&bh, OCFS2_BH_IGNORE_CACHE);
} else {
status = ocfs2_read_blocks_sync(osb, args->fi_blkno, 1, &bh); /* * If buffer is in jbd, then its checksum may not have been * computed as yet.
*/ if (!status && !buffer_jbd(bh)) { if (args->fi_flags & OCFS2_FI_FLAG_FILECHECK_CHK)
status = ocfs2_filecheck_validate_inode_block(
osb->sb, bh); elseif (args->fi_flags & OCFS2_FI_FLAG_FILECHECK_FIX)
status = ocfs2_filecheck_repair_inode_block(
osb->sb, bh); else
status = ocfs2_validate_inode_block(
osb->sb, bh);
}
} if (status < 0) {
mlog_errno(status); goto bail;
}
status = -EINVAL;
fe = (struct ocfs2_dinode *) bh->b_data;
/* * This is a code bug. Right now the caller needs to * understand whether it is asking for a system file inode or * not so the proper lock names can be built.
*/
mlog_bug_on_msg(!!(fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) !=
!!(args->fi_flags & OCFS2_FI_FLAG_SYSFILE), "Inode %llu: system file state is ambiguous\n",
(unsignedlonglong)args->fi_blkno);
if (S_ISCHR(le16_to_cpu(fe->i_mode)) ||
S_ISBLK(le16_to_cpu(fe->i_mode)))
inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
/* * This check will also skip truncate of inodes with inline * data and fast symlinks.
*/ if (fe->i_clusters) { if (ocfs2_should_order_data(inode))
ocfs2_begin_ordered_truncate(inode, 0);
handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); if (IS_ERR(handle)) {
status = PTR_ERR(handle);
handle = NULL;
mlog_errno(status); goto out;
}
status = ocfs2_journal_access_di(handle, INODE_CACHE(inode),
fe_bh,
OCFS2_JOURNAL_ACCESS_WRITE); if (status < 0) {
mlog_errno(status); goto out;
}
i_size_write(inode, 0);
status = ocfs2_mark_inode_dirty(handle, inode, fe_bh); if (status < 0) {
mlog_errno(status); goto out;
}
ocfs2_commit_trans(osb, handle);
handle = NULL;
status = ocfs2_commit_truncate(osb, inode, fe_bh); if (status < 0)
mlog_errno(status);
}
out: if (handle)
ocfs2_commit_trans(osb, handle); return status;
}
/* * Serialize with orphan dir recovery. If the process doing * recovery on this orphan dir does an iget() with the dir * i_rwsem held, we'll deadlock here. Instead we detect this * and exit early - recovery will wipe this inode for us.
*/ staticint ocfs2_check_orphan_recovery_state(struct ocfs2_super *osb, int slot)
{ int ret = 0;
spin_lock(&osb->osb_lock); if (ocfs2_node_map_test_bit(osb, &osb->osb_recovering_orphan_dirs, slot)) {
ret = -EDEADLK; goto out;
} /* This signals to the orphan recovery process that it should
* wait for us to handle the wipe. */
osb->osb_orphan_wipes[slot]++;
out:
spin_unlock(&osb->osb_lock);
trace_ocfs2_check_orphan_recovery_state(slot, ret); return ret;
}
staticvoid ocfs2_signal_wipe_completion(struct ocfs2_super *osb, int slot)
{
spin_lock(&osb->osb_lock);
osb->osb_orphan_wipes[slot]--;
spin_unlock(&osb->osb_lock);
if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) {
orphaned_slot = le16_to_cpu(di->i_orphaned_slot);
status = ocfs2_check_orphan_recovery_state(osb, orphaned_slot); if (status) return status;
orphan_dir_inode = ocfs2_get_system_file_inode(osb,
ORPHAN_DIR_SYSTEM_INODE,
orphaned_slot); if (!orphan_dir_inode) {
status = -ENOENT;
mlog_errno(status); goto bail;
}
/* Lock the orphan dir. The lock will be held for the entire * delete_inode operation. We do this now to avoid races with
* recovery completion on other nodes. */
inode_lock(orphan_dir_inode);
status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1); if (status < 0) {
inode_unlock(orphan_dir_inode);
mlog_errno(status); goto bail;
}
}
/* we do this while holding the orphan dir lock because we * don't want recovery being run from another node to try an * inode delete underneath us -- this will result in two nodes
* truncating the same file! */
status = ocfs2_truncate_for_delete(osb, inode, di_bh); if (status < 0) {
mlog_errno(status); goto bail_unlock_dir;
}
/* Remove any dir index tree */ if (S_ISDIR(inode->i_mode)) {
status = ocfs2_dx_dir_truncate(inode, di_bh); if (status) {
mlog_errno(status); goto bail_unlock_dir;
}
}
/*Free extended attribute resources associated with this inode.*/
status = ocfs2_xattr_remove(inode, di_bh); if (status < 0) {
mlog_errno(status); goto bail_unlock_dir;
}
status = ocfs2_remove_refcount_tree(inode, di_bh); if (status < 0) {
mlog_errno(status); goto bail_unlock_dir;
}
status = ocfs2_remove_inode(inode, di_bh, orphan_dir_inode,
orphan_dir_bh); if (status < 0)
mlog_errno(status);
bail_unlock_dir: if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR) return status;
/* There is a series of simple checks that should be done before a
* trylock is even considered. Encapsulate those in this function. */ staticint ocfs2_inode_is_valid_to_delete(struct inode *inode)
{ int ret = 0; struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
/* We shouldn't be getting here for the root directory
* inode.. */ if (inode == osb->root_inode) {
mlog(ML_ERROR, "Skipping delete of root inode.\n"); goto bail;
}
/* * If we're coming from downconvert_thread we can't go into our own * voting [hello, deadlock city!] so we cannot delete the inode. But * since we dropped last inode ref when downconverting dentry lock, * we cannot have the file open and thus the node doing unlink will * take care of deleting the inode.
*/ if (current == osb->dc_task) goto bail;
spin_lock(&oi->ip_lock); /* OCFS2 *never* deletes system files. This should technically * never get here as system file inodes should always have a
* positive link count. */ if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
mlog(ML_ERROR, "Skipping delete of system file %llu\n",
(unsignedlonglong)oi->ip_blkno); goto bail_unlock;
}
ret = 1;
bail_unlock:
spin_unlock(&oi->ip_lock);
bail: return ret;
}
/* Query the cluster to determine whether we should wipe an inode from * disk or not. *
* Requires the inode to have the cluster lock. */ staticint ocfs2_query_inode_wipe(struct inode *inode, struct buffer_head *di_bh, int *wipe)
{ int status = 0, reason = 0; struct ocfs2_inode_info *oi = OCFS2_I(inode); struct ocfs2_dinode *di;
/* While we were waiting for the cluster lock in * ocfs2_delete_inode, another node might have asked to delete
* the inode. Recheck our flags to catch this. */ if (!ocfs2_inode_is_valid_to_delete(inode)) {
reason = 1; goto bail;
}
/* Now that we have an up to date inode, we can double check
* the link count. */ if (inode->i_nlink) goto bail;
/* Do some basic inode verification... */
di = (struct ocfs2_dinode *) di_bh->b_data; if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL)) &&
!(oi->ip_flags & OCFS2_INODE_SKIP_ORPHAN_DIR)) { /* * Inodes in the orphan dir must have ORPHANED_FL. The only * inodes that come back out of the orphan dir are reflink * targets. A reflink target may be moved out of the orphan * dir between the time we scan the directory and the time we * process it. This would lead to HAS_REFCOUNT_FL being set but * ORPHANED_FL not.
*/ if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) {
reason = 2; goto bail;
}
/* for lack of a better error? */
status = -EEXIST;
mlog(ML_ERROR, "Inode %llu (on-disk %llu) not orphaned! " "Disk flags 0x%x, inode flags 0x%x\n",
(unsignedlonglong)oi->ip_blkno,
(unsignedlonglong)le64_to_cpu(di->i_blkno),
le32_to_cpu(di->i_flags), oi->ip_flags); goto bail;
}
/* has someone already deleted us?! baaad... */ if (di->i_dtime) {
status = -EEXIST;
mlog_errno(status); goto bail;
}
/* * This is how ocfs2 determines whether an inode is still live * within the cluster. Every node takes a shared read lock on * the inode open lock in ocfs2_read_locked_inode(). When we * get to ->delete_inode(), each node tries to convert it's * lock to an exclusive. Trylocks are serialized by the inode * meta data lock. If the upconvert succeeds, we know the inode * is no longer live and can be deleted. * * Though we call this with the meta data lock held, the * trylock keeps us from ABBA deadlock.
*/
status = ocfs2_try_open_lock(inode, 1); if (status == -EAGAIN) {
status = 0;
reason = 3; goto bail;
} if (status < 0) {
mlog_errno(status); goto bail;
}
/* Support function for ocfs2_delete_inode. Will help us keep the * inode data in a consistent state for clear_inode. Always truncates
* pages, optionally sync's them first. */ staticvoid ocfs2_cleanup_delete_inode(struct inode *inode, int sync_data)
{
trace_ocfs2_cleanup_delete_inode(
(unsignedlonglong)OCFS2_I(inode)->ip_blkno, sync_data); if (sync_data)
filemap_write_and_wait(inode->i_mapping);
truncate_inode_pages_final(&inode->i_data);
}
/* When we fail in read_inode() we mark inode as bad. The second test * catches the case when inode allocation fails before allocating
* a block for inode. */ if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno) goto bail;
if (!ocfs2_inode_is_valid_to_delete(inode)) { /* It's probably not necessary to truncate_inode_pages * here but we do it for safety anyway (it will most
* likely be a no-op anyway) */
ocfs2_cleanup_delete_inode(inode, 0); goto bail;
}
dquot_initialize(inode);
/* We want to block signals in delete_inode as the lock and * messaging paths may return us -ERESTARTSYS. Which would * cause us to exit early, resulting in inodes being orphaned
* forever. */
ocfs2_block_signals(&oldset);
/* * Synchronize us against ocfs2_get_dentry. We take this in * shared mode so that all nodes can still concurrently * process deletes.
*/
status = ocfs2_nfs_sync_lock(OCFS2_SB(inode->i_sb), 0); if (status < 0) {
mlog(ML_ERROR, "getting nfs sync lock(PR) failed %d\n", status);
ocfs2_cleanup_delete_inode(inode, 0); goto bail_unblock;
} /* Lock down the inode. This gives us an up to date view of * it's metadata (for verification), and allows us to * serialize delete_inode on multiple nodes. * * Even though we might be doing a truncate, we don't take the * allocation lock here as it won't be needed - nobody will * have the file open.
*/
status = ocfs2_inode_lock(inode, &di_bh, 1); if (status < 0) { if (status != -ENOENT)
mlog_errno(status);
ocfs2_cleanup_delete_inode(inode, 0); goto bail_unlock_nfs_sync;
}
di = (struct ocfs2_dinode *)di_bh->b_data; /* Skip inode deletion and wait for dio orphan entry recovered
* first */ if (unlikely(di->i_flags & cpu_to_le32(OCFS2_DIO_ORPHANED_FL))) {
ocfs2_cleanup_delete_inode(inode, 0); goto bail_unlock_inode;
}
/* Query the cluster. This will be the final decision made
* before we go ahead and wipe the inode. */
status = ocfs2_query_inode_wipe(inode, di_bh, &wipe); if (!wipe || status < 0) { /* Error and remote inode busy both mean we won't be * removing the inode, so they take almost the same
* path. */ if (status < 0)
mlog_errno(status);
/* Someone in the cluster has disallowed a wipe of * this inode, or it was never completely
* orphaned. Write out the pages and exit now. */
ocfs2_cleanup_delete_inode(inode, 1); goto bail_unlock_inode;
}
ocfs2_cleanup_delete_inode(inode, 0);
status = ocfs2_wipe_inode(inode, di_bh); if (status < 0) { if (status != -EDEADLK)
mlog_errno(status); goto bail_unlock_inode;
}
/* * Mark the inode as successfully deleted. * * This is important for ocfs2_clear_inode() as it will check * this flag and skip any checkpointing work * * ocfs2_stuff_meta_lvb() also uses this flag to invalidate * the LVB for other nodes.
*/
OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED;
/* To prevent remote deletes we hold open lock before, now it
* is time to unlock PR and EX open locks. */
ocfs2_open_unlock(inode);
/* Do these before all the other work so that we don't bounce
* the downconvert thread while waiting to destroy the locks. */
ocfs2_mark_lockres_freeing(osb, &oi->ip_rw_lockres);
ocfs2_mark_lockres_freeing(osb, &oi->ip_inode_lockres);
ocfs2_mark_lockres_freeing(osb, &oi->ip_open_lockres);
/* We very well may get a clear_inode before all an inodes * metadata has hit disk. Of course, we can't drop any cluster * locks until the journal has finished with it. The only * exception here are successfully wiped inodes - their * metadata can now be considered to be part of the system
* inodes from which it came. */ if (!(oi->ip_flags & OCFS2_INODE_DELETED))
ocfs2_checkpoint_inode(inode);
mlog_bug_on_msg(!list_empty(&oi->ip_io_markers), "Clear inode of %llu, inode has io markers\n",
(unsignedlonglong)oi->ip_blkno);
mlog_bug_on_msg(!list_empty(&oi->ip_unwritten_list), "Clear inode of %llu, inode has unwritten extents\n",
(unsignedlonglong)oi->ip_blkno);
ocfs2_extent_map_trunc(inode, 0);
status = ocfs2_drop_inode_locks(inode); if (status < 0)
mlog_errno(status);
mlog_bug_on_msg(INODE_CACHE(inode)->ci_num_cached, "Clear inode of %llu, inode has %u cache items\n",
(unsignedlonglong)oi->ip_blkno,
INODE_CACHE(inode)->ci_num_cached);
mlog_bug_on_msg(!(INODE_CACHE(inode)->ci_flags & OCFS2_CACHE_FL_INLINE), "Clear inode of %llu, inode has a bad flag\n",
(unsignedlonglong)oi->ip_blkno);
mlog_bug_on_msg(spin_is_locked(&oi->ip_lock), "Clear inode of %llu, inode is locked\n",
(unsignedlonglong)oi->ip_blkno);
mlog_bug_on_msg(!mutex_trylock(&oi->ip_io_mutex), "Clear inode of %llu, io_mutex is locked\n",
(unsignedlonglong)oi->ip_blkno);
mutex_unlock(&oi->ip_io_mutex);
/* * down_trylock() returns 0, down_write_trylock() returns 1 * kernel 1, world 0
*/
mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem), "Clear inode of %llu, alloc_sem is locked\n",
(unsignedlonglong)oi->ip_blkno);
up_write(&oi->ip_alloc_sem);
mlog_bug_on_msg(oi->ip_open_count, "Clear inode of %llu has open count %d\n",
(unsignedlonglong)oi->ip_blkno, oi->ip_open_count);
/* Clear all other flags. */
oi->ip_flags = 0;
oi->ip_dir_start_lookup = 0;
oi->ip_blkno = 0ULL;
/* * ip_jinode is used to track txns against this inode. We ensure that * the journal is flushed before journal shutdown. Thus it is safe to * have inodes get cleaned up after journal shutdown.
*/ if (!osb->journal) return;
/* Called under inode_lock, with no more references on the * struct inode, so it's safe here to check the flags field
* and to manipulate i_nlink without any other locks. */ int ocfs2_drop_inode(struct inode *inode)
{ struct ocfs2_inode_info *oi = OCFS2_I(inode);
spin_lock(&OCFS2_I(inode)->ip_lock); if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) {
spin_unlock(&OCFS2_I(inode)->ip_lock);
status = -ENOENT; goto bail;
}
spin_unlock(&OCFS2_I(inode)->ip_lock);
/* Let ocfs2_inode_lock do the work of updating our struct
* inode for us. */
status = ocfs2_inode_lock(inode, NULL, 0); if (status < 0) { if (status != -ENOENT)
mlog_errno(status); goto bail;
}
ocfs2_inode_unlock(inode, 0);
bail: return status;
}
/* * Updates a disk inode from a * struct inode. * Only takes ip_lock.
*/ int ocfs2_mark_inode_dirty(handle_t *handle, struct inode *inode, struct buffer_head *bh)
{ int status; struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
/* * * Updates a struct inode from a disk inode. * does no i/o, only takes ip_lock.
*/ void ocfs2_refresh_inode(struct inode *inode, struct ocfs2_dinode *fe)
{
spin_lock(&OCFS2_I(inode)->ip_lock);
/* * If the ecc fails, we return the error but otherwise * leave the filesystem running. We know any error is * local to this block.
*/
rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &di->i_check); if (rc) {
mlog(ML_ERROR, "Checksum failed for dinode %llu\n",
(unsignedlonglong)bh->b_blocknr); goto bail;
}
/* * Call ocfs2_validate_meta_ecc() first since it has ecc repair * function, but we should not return error immediately when ecc * validation fails, because the reason is quite likely the invalid * inode number inputted.
*/
rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &di->i_check); if (rc) {
mlog(ML_ERROR, "Filecheck: checksum failed for dinode %llu\n",
(unsignedlonglong)bh->b_blocknr);
rc = -OCFS2_FILECHECK_ERR_BLOCKECC;
}
if (!(di->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { /* Cannot just add VALID_FL flag back as a fix, * need more things to check here.
*/ return -OCFS2_FILECHECK_ERR_VALIDFLAG;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.