From 7407323847ce2fdf665b915f5b465056302a998f Mon Sep 17 00:00:00 2001 From: adilger Date: Mon, 24 Jun 2002 16:57:47 +0000 Subject: [PATCH] Fix o_valid and o_size for truncate through osc/ost/filterobd (on HEAD). This should also remove the need to explicitly set mtime/ctime in ll_truncate(), but that has not yet been tested and causes no real harm. --- lustre/include/linux/lustre_idl.h | 2 +- lustre/llite/rw.c | 7 ++++--- lustre/obdfilter/filter.c | 7 ++++--- lustre/osc/osc_request.c | 3 +-- lustre/ost/ost_handler.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index c4d5e3d..b1e41bb 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -131,7 +131,7 @@ struct obdo { struct obd_ops *o_op; }; -#define OBD_MD_FLALL 0xffffffff +#define OBD_MD_FLALL (0xffffffff) #define OBD_MD_FLID (0x00000001) #define OBD_MD_FLATIME (0x00000002) #define OBD_MD_FLMTIME (0x00000004) diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 8993695..b18abee 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -197,11 +197,12 @@ void ll_truncate(struct inode *inode) inode->i_mtime = inode->i_ctime = CURRENT_TIME; return; } - CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n", + CDEBUG(D_INFO, "calling punch for %ld (all bytes after %Ld)\n", (long)oa->o_id, (unsigned long long)oa->o_size); oa->o_size = inode->i_size; - oa->o_valid = OBD_MD_FLSIZE; - err = obd_punch(ll_i2obdconn(inode), oa, 0, oa->o_size); + oa->o_valid = OBD_MD_FLSIZE | OBD_MD_FLID; + /* truncate == punch from i_size onwards */ + err = obd_punch(ll_i2obdconn(inode), oa, -1 - oa->o_size, oa->o_size); if (err) CERROR("obd_truncate fails (%d)\n", err); else diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 2bb1be8..545b438 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -560,8 +560,11 @@ static int filter_setattr(struct obd_conn *conn, struct obdo *oa) else rc = inode_setattr(inode, &iattr); pop_ctxt(&saved); - if (iattr.ia_mode & ATTR_SIZE) + if (iattr.ia_mode & ATTR_SIZE) { up(&inode->i_sem); + oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLCTIME | OBD_MD_FLMTIME; + obdo_from_inode(oa, inode); + } unlock_kernel(); CDEBUG(D_INODE, "put dentry %p, count = %d\n", inode, @@ -713,9 +716,7 @@ static int filter_truncate(struct obd_conn *conn, struct obdo *oa, CDEBUG(D_INODE, "calling truncate for object #%Ld, valid = %x, " "o_size = %Ld\n", oa->o_id, oa->o_valid, oa->o_size); - oa->o_valid = OBD_MD_FLSIZE; error = filter_setattr(conn, oa); - oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLCTIME | OBD_MD_FLMTIME; RETURN(error); } diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 5703168..a1db49a 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -319,9 +319,8 @@ static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count, body = lustre_msg_buf(request->rq_reqmsg, 0); memcpy(&body->oa, oa, sizeof(*oa)); body->connid = conn->oc_id; - body->oa.o_valid = ~0; - body->oa.o_size = offset; body->oa.o_blocks = count; + body->oa.o_valid |= OBD_MD_FLBLOCKS; request->rq_replen = lustre_msg_size(1, &size); diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 7d45824..7b0600e 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -159,7 +159,7 @@ static int ost_punch(struct ost_obd *ost, struct ptlrpc_request *req) repbody = lustre_msg_buf(req->rq_repmsg, 0); memcpy(&repbody->oa, &body->oa, sizeof(body->oa)); req->rq_status = obd_punch(&conn, &repbody->oa, - repbody->oa.o_size, repbody->oa.o_blocks); + repbody->oa.o_blocks, repbody->oa.o_size); RETURN(0); } -- 1.8.3.1