X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Focfs2%2Fvote.c;h=0afd8b9af70fa3691c2a98c3c66716d259982cda;hb=refs%2Fheads%2Fvserver;hp=021978e0576b641c8777a2ce2d8fc62f86e9f187;hpb=76828883507a47dae78837ab5dec5a5b4513c667;p=linux-2.6.git diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c index 021978e05..0afd8b9af 100644 --- a/fs/ocfs2/vote.c +++ b/fs/ocfs2/vote.c @@ -74,9 +74,6 @@ struct ocfs2_vote_msg __be32 v_orphaned_slot; /* Used during delete votes */ __be32 v_nlink; /* Used during unlink votes */ } md1; /* Message type dependant 1 */ - __be32 v_unlink_namelen; - __be64 v_unlink_parent; - u8 v_unlink_dirent[OCFS2_VOTE_FILENAME_LEN]; }; /* Responses are given these values to maintain backwards @@ -100,8 +97,6 @@ struct ocfs2_vote_work { enum ocfs2_vote_request { OCFS2_VOTE_REQ_INVALID = 0, OCFS2_VOTE_REQ_DELETE, - OCFS2_VOTE_REQ_UNLINK, - OCFS2_VOTE_REQ_RENAME, OCFS2_VOTE_REQ_MOUNT, OCFS2_VOTE_REQ_UMOUNT, OCFS2_VOTE_REQ_LAST @@ -190,20 +185,21 @@ static int ocfs2_process_delete_request(struct inode *inode, OCFS2_INVALID_SLOT && OCFS2_I(inode)->ip_orphaned_slot != (*orphaned_slot), - "Inode %"MLFu64": This node thinks it's " + "Inode %llu: This node thinks it's " "orphaned in slot %d, messaged it's in %d\n", - OCFS2_I(inode)->ip_blkno, + (unsigned long long)OCFS2_I(inode)->ip_blkno, OCFS2_I(inode)->ip_orphaned_slot, *orphaned_slot); - mlog(0, "Setting orphaned slot for inode %"MLFu64" to %d\n", - OCFS2_I(inode)->ip_blkno, *orphaned_slot); + mlog(0, "Setting orphaned slot for inode %llu to %d\n", + (unsigned long long)OCFS2_I(inode)->ip_blkno, + *orphaned_slot); OCFS2_I(inode)->ip_orphaned_slot = *orphaned_slot; } else { - mlog(0, "Sending back orphaned slot %d for inode %"MLFu64"\n", + mlog(0, "Sending back orphaned slot %d for inode %llu\n", OCFS2_I(inode)->ip_orphaned_slot, - OCFS2_I(inode)->ip_blkno); + (unsigned long long)OCFS2_I(inode)->ip_blkno); *orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; } @@ -226,8 +222,8 @@ static int ocfs2_process_delete_request(struct inode *inode, } if (filemap_fdatawrite(inode->i_mapping)) { - mlog(ML_ERROR, "Could not sync inode %"MLFu64" for delete!\n", - OCFS2_I(inode)->ip_blkno); + mlog(ML_ERROR, "Could not sync inode %llu for delete!\n", + (unsigned long long)OCFS2_I(inode)->ip_blkno); goto done; } sync_mapping_buffers(inode->i_mapping); @@ -260,103 +256,13 @@ done: return response; } -static int ocfs2_match_dentry(struct dentry *dentry, - u64 parent_blkno, - unsigned int namelen, - const char *name) -{ - struct inode *parent; - - if (!dentry->d_parent) { - mlog(0, "Detached from parent.\n"); - return 0; - } - - parent = dentry->d_parent->d_inode; - /* Negative parent dentry? */ - if (!parent) - return 0; - - /* Name is in a different directory. */ - if (OCFS2_I(parent)->ip_blkno != parent_blkno) - return 0; - - if (dentry->d_name.len != namelen) - return 0; - - /* comparison above guarantees this is safe. */ - if (memcmp(dentry->d_name.name, name, namelen)) - return 0; - - return 1; -} - -static void ocfs2_process_dentry_request(struct inode *inode, - int rename, - unsigned int new_nlink, - u64 parent_blkno, - unsigned int namelen, - const char *name) -{ - struct dentry *dentry = NULL; - struct list_head *p; - struct ocfs2_inode_info *oi = OCFS2_I(inode); - - mlog(0, "parent %"MLFu64", namelen = %u, name = %.*s\n", parent_blkno, - namelen, namelen, name); - - spin_lock(&dcache_lock); - - /* Another node is removing this name from the system. It is - * up to us to find the corresponding dentry and if it exists, - * unhash it from the dcache. */ - list_for_each(p, &inode->i_dentry) { - dentry = list_entry(p, struct dentry, d_alias); - - if (ocfs2_match_dentry(dentry, parent_blkno, namelen, name)) { - mlog(0, "dentry found: %.*s\n", - dentry->d_name.len, dentry->d_name.name); - - dget_locked(dentry); - break; - } - - dentry = NULL; - } - - spin_unlock(&dcache_lock); - - if (dentry) { - d_delete(dentry); - dput(dentry); - } - - /* rename votes don't send link counts */ - if (!rename) { - mlog(0, "new_nlink = %u\n", new_nlink); - - /* We don't have the proper locks here to directly - * change i_nlink and besides, the vote is sent - * *before* the operation so it may have failed on the - * other node. This passes a hint to ocfs2_drop_inode - * to force ocfs2_delete_inode, who will take the - * proper cluster locks to sort things out. */ - if (new_nlink == 0) { - spin_lock(&oi->ip_lock); - oi->ip_flags |= OCFS2_INODE_MAYBE_ORPHANED; - spin_unlock(&OCFS2_I(inode)->ip_lock); - } - } -} - static void ocfs2_process_vote(struct ocfs2_super *osb, struct ocfs2_vote_msg *msg) { int net_status, vote_response; int orphaned_slot = 0; - int rename = 0; - unsigned int node_num, generation, new_nlink, namelen; - u64 blkno, parent_blkno; + unsigned int node_num, generation; + u64 blkno; enum ocfs2_vote_request request; struct inode *inode = NULL; struct ocfs2_msg_hdr *hdr = &msg->v_hdr; @@ -370,9 +276,10 @@ static void ocfs2_process_vote(struct ocfs2_super *osb, if (request == OCFS2_VOTE_REQ_DELETE) orphaned_slot = be32_to_cpu(msg->md1.v_orphaned_slot); - mlog(0, "processing vote: request = %u, blkno = %"MLFu64", " + mlog(0, "processing vote: request = %u, blkno = %llu, " "generation = %u, node_num = %u, priv1 = %u\n", request, - blkno, generation, node_num, be32_to_cpu(msg->md1.v_generic1)); + (unsigned long long)blkno, generation, node_num, + be32_to_cpu(msg->md1.v_generic1)); if (!ocfs2_is_valid_vote_request(request)) { mlog(ML_ERROR, "Invalid vote request %d from node %u\n", @@ -419,11 +326,12 @@ static void ocfs2_process_vote(struct ocfs2_super *osb, * we had not found an inode in the first place. */ if (inode->i_generation != generation) { mlog(0, "generation passed %u != inode generation = %u, " - "ip_flags = %x, ip_blkno = %"MLFu64", msg %"MLFu64", " - "i_count = %u, message type = %u\n", - generation, inode->i_generation, OCFS2_I(inode)->ip_flags, - OCFS2_I(inode)->ip_blkno, blkno, - atomic_read(&inode->i_count), request); + "ip_flags = %x, ip_blkno = %llu, msg %llu, i_count = %u, " + "message type = %u\n", generation, inode->i_generation, + OCFS2_I(inode)->ip_flags, + (unsigned long long)OCFS2_I(inode)->ip_blkno, + (unsigned long long)blkno, atomic_read(&inode->i_count), + request); iput(inode); inode = NULL; goto respond; @@ -434,18 +342,6 @@ static void ocfs2_process_vote(struct ocfs2_super *osb, vote_response = ocfs2_process_delete_request(inode, &orphaned_slot); break; - case OCFS2_VOTE_REQ_RENAME: - rename = 1; - /* fall through */ - case OCFS2_VOTE_REQ_UNLINK: - parent_blkno = be64_to_cpu(msg->v_unlink_parent); - namelen = be32_to_cpu(msg->v_unlink_namelen); - /* new_nlink will be ignored in case of a rename vote */ - new_nlink = be32_to_cpu(msg->md1.v_nlink); - ocfs2_process_dentry_request(inode, rename, new_nlink, - parent_blkno, namelen, - msg->v_unlink_dirent); - break; default: mlog(ML_ERROR, "node %u, invalid request: %u\n", node_num, request); @@ -583,7 +479,7 @@ static struct ocfs2_net_wait_ctxt *ocfs2_new_net_wait_ctxt(unsigned int response { struct ocfs2_net_wait_ctxt *w; - w = kcalloc(1, sizeof(*w), GFP_KERNEL); + w = kzalloc(sizeof(*w), GFP_NOFS); if (!w) { mlog_errno(-ENOMEM); goto bail; @@ -746,7 +642,7 @@ static struct ocfs2_vote_msg * ocfs2_new_vote_request(struct ocfs2_super *osb, BUG_ON(!ocfs2_is_valid_vote_request(type)); - request = kcalloc(1, sizeof(*request), GFP_KERNEL); + request = kzalloc(sizeof(*request), GFP_NOFS); if (!request) { mlog_errno(-ENOMEM); } else { @@ -830,8 +726,9 @@ static void ocfs2_delete_response_cb(void *priv, orphaned_slot = be32_to_cpu(resp->r_orphaned_slot); node = be32_to_cpu(resp->r_hdr.h_node_num); - mlog(0, "node %d tells us that inode %"MLFu64" is orphaned in slot " - "%d\n", node, OCFS2_I(inode)->ip_blkno, orphaned_slot); + mlog(0, "node %d tells us that inode %llu is orphaned in slot %d\n", + node, (unsigned long long)OCFS2_I(inode)->ip_blkno, + orphaned_slot); /* The other node may not actually know which slot the inode * is orphaned in. */ @@ -845,9 +742,9 @@ static void ocfs2_delete_response_cb(void *priv, spin_lock(&OCFS2_I(inode)->ip_lock); mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != orphaned_slot && OCFS2_I(inode)->ip_orphaned_slot - != OCFS2_INVALID_SLOT, "Inode %"MLFu64": Node %d " - "says it's orphaned in slot %d, we think it's in %d\n", - OCFS2_I(inode)->ip_blkno, + != OCFS2_INVALID_SLOT, "Inode %llu: Node %d says it's " + "orphaned in slot %d, we think it's in %d\n", + (unsigned long long)OCFS2_I(inode)->ip_blkno, be32_to_cpu(resp->r_hdr.h_node_num), orphaned_slot, OCFS2_I(inode)->ip_orphaned_slot); @@ -869,8 +766,8 @@ int ocfs2_request_delete_vote(struct inode *inode) delete_cb.rc_cb = ocfs2_delete_response_cb; delete_cb.rc_priv = inode; - mlog(0, "Inode %"MLFu64", we start thinking orphaned slot is %d\n", - OCFS2_I(inode)->ip_blkno, orphaned_slot); + mlog(0, "Inode %llu, we start thinking orphaned slot is %d\n", + (unsigned long long)OCFS2_I(inode)->ip_blkno, orphaned_slot); status = -ENOMEM; request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, @@ -885,75 +782,6 @@ int ocfs2_request_delete_vote(struct inode *inode) return status; } -static void ocfs2_setup_unlink_vote(struct ocfs2_vote_msg *request, - struct dentry *dentry) -{ - struct inode *parent = dentry->d_parent->d_inode; - - /* We need some values which will uniquely identify a dentry - * on the other nodes so that they can find it and run - * d_delete against it. Parent directory block and full name - * should suffice. */ - - mlog(0, "unlink/rename request: parent: %"MLFu64" name: %.*s\n", - OCFS2_I(parent)->ip_blkno, dentry->d_name.len, - dentry->d_name.name); - - request->v_unlink_parent = cpu_to_be64(OCFS2_I(parent)->ip_blkno); - request->v_unlink_namelen = cpu_to_be32(dentry->d_name.len); - memcpy(request->v_unlink_dirent, dentry->d_name.name, - dentry->d_name.len); -} - -int ocfs2_request_unlink_vote(struct inode *inode, - struct dentry *dentry, - unsigned int nlink) -{ - int status; - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - struct ocfs2_vote_msg *request; - - if (dentry->d_name.len > OCFS2_VOTE_FILENAME_LEN) - return -ENAMETOOLONG; - - status = -ENOMEM; - request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, - inode->i_generation, - OCFS2_VOTE_REQ_UNLINK, nlink); - if (request) { - ocfs2_setup_unlink_vote(request, dentry); - - status = ocfs2_request_vote(inode, request, NULL); - - kfree(request); - } - return status; -} - -int ocfs2_request_rename_vote(struct inode *inode, - struct dentry *dentry) -{ - int status; - struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - struct ocfs2_vote_msg *request; - - if (dentry->d_name.len > OCFS2_VOTE_FILENAME_LEN) - return -ENAMETOOLONG; - - status = -ENOMEM; - request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, - inode->i_generation, - OCFS2_VOTE_REQ_RENAME, 0); - if (request) { - ocfs2_setup_unlink_vote(request, dentry); - - status = ocfs2_request_vote(inode, request, NULL); - - kfree(request); - } - return status; -} - int ocfs2_request_mount_vote(struct ocfs2_super *osb) { int status; @@ -984,9 +812,7 @@ int ocfs2_request_mount_vote(struct ocfs2_super *osb) } bail: - if (request) - kfree(request); - + kfree(request); return status; } @@ -1017,9 +843,7 @@ int ocfs2_request_umount_vote(struct ocfs2_super *osb) } bail: - if (request) - kfree(request); - + kfree(request); return status; } @@ -1082,7 +906,8 @@ static int ocfs2_handle_response_message(struct o2net_msg *msg, mlog(0, "received response message:\n"); mlog(0, "h_response_id = %u\n", response_id); mlog(0, "h_request = %u\n", be32_to_cpu(resp->r_hdr.h_request)); - mlog(0, "h_blkno = %"MLFu64"\n", be64_to_cpu(resp->r_hdr.h_blkno)); + mlog(0, "h_blkno = %llu\n", + (unsigned long long)be64_to_cpu(resp->r_hdr.h_blkno)); mlog(0, "h_generation = %u\n", be32_to_cpu(resp->r_hdr.h_generation)); mlog(0, "h_node_num = %u\n", node_num); mlog(0, "r_response = %d\n", response_status); @@ -1124,7 +949,7 @@ static int ocfs2_handle_vote_message(struct o2net_msg *msg, struct ocfs2_super *osb = data; struct ocfs2_vote_work *work; - work = kmalloc(sizeof(struct ocfs2_vote_work), GFP_KERNEL); + work = kmalloc(sizeof(struct ocfs2_vote_work), GFP_NOFS); if (!work) { status = -ENOMEM; mlog_errno(status); @@ -1138,8 +963,8 @@ static int ocfs2_handle_vote_message(struct o2net_msg *msg, mlog(0, "h_response_id = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_response_id)); mlog(0, "h_request = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_request)); - mlog(0, "h_blkno = %"MLFu64"\n", - be64_to_cpu(work->w_msg.v_hdr.h_blkno)); + mlog(0, "h_blkno = %llu\n", + (unsigned long long)be64_to_cpu(work->w_msg.v_hdr.h_blkno)); mlog(0, "h_generation = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_generation)); mlog(0, "h_node_num = %u\n", @@ -1175,6 +1000,9 @@ int ocfs2_register_net_handlers(struct ocfs2_super *osb) { int status = 0; + if (ocfs2_mount_local(osb)) + return 0; + status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, osb->net_key, sizeof(struct ocfs2_response_msg),