From: adilger Date: Tue, 27 Aug 2002 06:25:29 +0000 (+0000) Subject: Whenever we get the file size from the OST, also get the blocks count at X-Git-Tag: 0.5.5~45 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=0d9c0b14e71a1aa2a27355bb4e985988e7977dc6;p=fs%2Flustre-release.git Whenever we get the file size from the OST, also get the blocks count at the same time, since this is free. --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 9efd885..e4b69fe 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -37,7 +37,7 @@ static int ll_file_open(struct inode *inode, struct file *file) struct ptlrpc_request *req = NULL; struct ll_file_data *fd; struct obdo *oa = NULL; - struct lov_stripe_md *md = NULL; + struct lov_stripe_md *md = NULL; struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); ENTRY; @@ -182,16 +182,12 @@ int ll_file_size(struct inode *inode, struct lov_stripe_md *md) RETURN(rc); } - /* FIXME: I don't like this; why doesn't osc_getattr get o_id from md - * like lov_getattr? --phil */ oa.o_id = md->lmd_object_id; oa.o_mode = S_IFREG; oa.o_valid = OBD_MD_FLID|OBD_MD_FLMODE|OBD_MD_FLSIZE|OBD_MD_FLBLOCKS; rc = obd_getattr(&sbi->ll_osc_conn, &oa, md); - if (!rc) { - inode->i_size = oa.o_size; - inode->i_blocks = oa.o_blocks; - } + if (!rc) + obdo_to_inode(inode, &oa, oa.o_valid); err = ll_size_unlock(inode, md, LCK_PR, lockhs); if (err != ELDLM_OK) { @@ -237,7 +233,8 @@ static int ll_file_release(struct inode *inode, struct file *file) oa.o_id = lli->lli_smd->lmd_object_id; oa.o_mode = S_IFREG; - oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE; + oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE | + OBD_MD_FLBLOCKS; rc = obd_getattr(&sbi->ll_osc_conn, &oa, lli->lli_smd); if (!rc) { struct iattr attr; @@ -248,6 +245,8 @@ static int ll_file_release(struct inode *inode, struct file *file) attr.ia_atime = inode->i_atime; attr.ia_size = oa.o_size; + inode->i_blocks = oa.o_blocks; + /* XXX: this introduces a small race that we should * evaluate */ rc = ll_inode_setattr(inode, &attr, 0); @@ -421,11 +420,14 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos) oa.o_id = md->lmd_object_id; oa.o_mode = inode->i_mode; - oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE; + oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE | + OBD_MD_FLBLOCKS; retval = obd_getattr(&sbi->ll_osc_conn, &oa, md); if (retval) GOTO(out_eof, retval); + *ppos = oa.o_size; + obdo_to_inode(inode, &oa, oa.o_valid); } if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK)) {