From e5654d8ed0b2903e30063dd4355e5a2eb84f07b5 Mon Sep 17 00:00:00 2001 From: vitaly Date: Wed, 20 Sep 2006 16:59:33 +0000 Subject: [PATCH] Branch b_new_cmd b=22564 Returns -EAGAIN instead of EAGAIN to clients when attribute update is needed. Sets ldiskfs_inode_info.i_disksize to inode size in osd_inode_setattr to store it correctly on the disk. --- lustre/liblustre/file.c | 2 +- lustre/liblustre/super.c | 2 +- lustre/llite/file.c | 2 +- lustre/llite/llite_close.c | 2 +- lustre/llite/llite_lib.c | 2 +- lustre/mdt/mdt_open.c | 12 ++++++------ lustre/mdt/mdt_reint.c | 5 +---- lustre/osd/osd_handler.c | 2 +- 8 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index c0c26e3..87095bd 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -386,7 +386,7 @@ int llu_md_close(struct obd_export *md_exp, struct inode *inode) memcpy(&op_data.handle, &och->och_fh, sizeof(op_data.handle)); rc = md_close(md_exp, &op_data, och, &req); - if (rc == EAGAIN) { + if (rc == -EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ rc = llu_sizeonmds_update(inode, &och->och_fh); diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 9c40ef1..89a14b5 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -673,7 +673,7 @@ static int llu_setattr_done_writing(struct inode *inode, op_data->flags = MF_EPOCH_CLOSE | MF_SOM_CHANGE; rc = md_done_writing(llu_i2sbi(inode)->ll_md_exp, op_data, NULL); - if (rc == EAGAIN) { + if (rc == -EAGAIN) { /* MDS has instructed us to obtain Size-on-MDS attribute * from OSTs and send setattr to back to MDS. */ rc = llu_sizeonmds_update(inode, &op_data->handle); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 4a1f8af..42746f7 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -137,7 +137,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, ll_prepare_close(inode, op_data, och); epoch_close = (op_data->flags & MF_EPOCH_CLOSE); rc = md_close(md_exp, op_data, och, &req); - if (rc == EAGAIN) { + if (rc == -EAGAIN) { /* This close must have closed the epoch. */ LASSERT(epoch_close); /* MDS has instructed us to obtain Size-on-MDS attribute from diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index f49b21f..0a83605 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -199,7 +199,7 @@ static void ll_done_writing(struct inode *inode) rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, och); OBD_FREE_PTR(op_data); - if (rc == EAGAIN) { + if (rc == -EAGAIN) { /* MDS has instructed us to obtain Size-on-MDS attribute from * OSTs and send setattr to back to MDS. */ rc = ll_sizeonmds_update(inode, &och->och_fh); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 53bf092..87b7b42 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1248,7 +1248,7 @@ static int ll_setattr_done_writing(struct inode *inode, op_data->flags = MF_EPOCH_CLOSE | MF_SOM_CHANGE; rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, op_data, NULL); - if (rc == EAGAIN) { + if (rc == -EAGAIN) { /* MDS has instructed us to obtain Size-on-MDS attribute * from OSTs and send setattr to back to MDS. */ rc = ll_sizeonmds_update(inode, &op_data->handle); diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 207b992..ad36a6f 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -178,7 +178,7 @@ static int mdt_sizeonmds_update(struct mdt_thread_info *info, /* Epoch closes. * Returns 1 if epoch does not close. * Returns 0 if epoch closes. - * Returns EAGAIN if epoch closes but an Size-on-MDS Update is still needed + * Returns -EAGAIN if epoch closes but an Size-on-MDS Update is still needed * from the client. */ static int mdt_epoch_close(struct mdt_thread_info *info, struct mdt_object *o) { @@ -213,11 +213,11 @@ static int mdt_epoch_close(struct mdt_thread_info *info, struct mdt_object *o) /* Some previous writer changed the attribute. * Do not beleive to the current Size-on-MDS * update, re-ask client. */ - rc = EAGAIN; + rc = -EAGAIN; } else if (!(la->la_valid & LA_SIZE) && achange) { /* Attributes were changed by the last writer * only but no Size-on-MDS update is received.*/ - rc = EAGAIN; + rc = -EAGAIN; } } @@ -762,17 +762,17 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd) if (!MFD_CLOSED(mode)) rc = mo_close(info->mti_ctxt, next, ma); - else if (ret == EAGAIN) + else if (ret == -EAGAIN) rc = mo_attr_get(info->mti_ctxt, next, ma); /* If the object is unlinked, do not try to re-enable SIZEONMDS */ - if ((ret == EAGAIN) && (ma->ma_valid & MA_INODE) && + if ((ret == -EAGAIN) && (ma->ma_valid & MA_INODE) && (ma->ma_attr.la_nlink == 0)) { ret = 0; } - if ((ret == EAGAIN) || (ret == 1)) { + if ((ret == -EAGAIN) || (ret == 1)) { struct mdt_export_data *med; /* The epoch has not closed or Size-on-MDS update is needed. * Put mfd back into the list. */ diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index aec45f2..52d0ae5 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -123,7 +123,6 @@ static int mdt_md_mkobj(struct mdt_thread_info *info) int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo, int flags) { struct md_attr *ma = &info->mti_attr; - struct md_object *next; struct mdt_lock_handle *lh; int som_update = 0; int rc; @@ -153,11 +152,9 @@ int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo, int flags) /* Setattrs are syncronized through dlm lock taken above. If another * epoch started, its attributes may be already flushed on disk, * skip setattr. */ - next = mdt_object_child(mo); if (som_update && (info->mti_epoch->ioepoch != mo->mot_ioepoch)) GOTO(out, rc = 0); - next = mdt_object_child(mo); if (lu_object_assert_not_exists(&mo->mot_obj.mo_lu)) GOTO(out, rc = -ENOENT); @@ -166,7 +163,7 @@ int mdt_attr_set(struct mdt_thread_info *info, struct mdt_object *mo, int flags) OBD_FAIL_MDS_REINT_SETATTR_WRITE); /* all attrs are packed into mti_attr in unpack_setattr */ - rc = mo_attr_set(info->mti_ctxt, next, ma); + rc = mo_attr_set(info->mti_ctxt, mdt_object_child(mo), ma); if (rc != 0) GOTO(out, rc); diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 80ced39..d4ba1ac 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -702,7 +702,7 @@ static int osd_inode_setattr(const struct lu_context *ctx, if (bits & LA_MTIME) inode->i_mtime = *osd_inode_time(ctx, inode, attr->la_mtime); if (bits & LA_SIZE) - inode->i_size = attr->la_size; + LDISKFS_I(inode)->i_disksize = inode->i_size = attr->la_size; if (bits & LA_BLOCKS) inode->i_blocks = attr->la_blocks; if (bits & LA_MODE) -- 1.8.3.1