Whamcloud - gitweb
- add the truncate obd call
authorbraam <braam>
Mon, 25 Feb 2002 15:49:21 +0000 (15:49 +0000)
committerbraam <braam>
Mon, 25 Feb 2002 15:49:21 +0000 (15:49 +0000)
lustre/include/linux/lustre_idl.h
lustre/osc/osc_request.c
lustre/ost/ost_handler.c

index dba1809..7da184b 100644 (file)
@@ -55,6 +55,7 @@
 #define OST_GET_INFO   6
 #define OST_CONNECT    7
 #define OST_DISCONNECT 8
+#define OST_PUNCH      9
 
 /* packet types */
 #define OST_TYPE_REQ 1
index 8fefa77..587629c 100644 (file)
@@ -281,6 +281,39 @@ static int osc_create(struct obd_conn *conn, struct obdo *oa)
        return 0;
 }
 
+static int osc_punch(struct obd_conn *conn, struct obdo *oa, obd_size count, obd_off offset)
+{
+       struct ptlrpc_request *request;
+       int rc; 
+
+       if (!oa) { 
+               CERROR("oa NULL\n"); 
+       }
+       request = ost_prep_req(OST_PUNCH, 0, NULL, 0, NULL);
+       if (!request) { 
+               CERROR("cannot pack req!\n"); 
+               return -ENOMEM;
+       }
+       
+       memcpy(&request->rq_req.ost->oa, oa, sizeof(*oa));
+       request->rq_req.ost->oa.o_valid = ~0;
+       request->rq_req.ost->oa.o_size = offset;
+       request->rq_req.ost->oa.o_blocks = count;
+       request->rq_replen = 
+               sizeof(struct ptlrep_hdr) + sizeof(struct ost_rep);
+       
+       rc = osc_queue_wait(conn, request);
+       if (rc) { 
+               EXIT;
+               goto out;
+       }
+       memcpy(oa, &request->rq_rep.ost->oa, sizeof(*oa));
+
+ out:
+       osc_free_req(request);
+       return 0;
+}
+
 static int osc_destroy(struct obd_conn *conn, struct obdo *oa)
 {
        struct ptlrpc_request *request;
@@ -459,7 +492,8 @@ struct obd_ops osc_obd_ops = {
        o_setattr: osc_setattr,
        o_connect: osc_connect,
        o_disconnect: osc_disconnect,
-       o_brw: osc_brw
+       o_brw: osc_brw,
+       o_punch: osc_punch
 };
 
 static int __init osc_init(void)
index 6b8f813..45e8238 100644 (file)
@@ -208,6 +208,34 @@ static int ost_create(struct ost_obd *ost, struct ptlrpc_request *req)
        return 0;
 }
 
+static int ost_punch(struct ost_obd *ost, struct ptlrpc_request *req)
+{
+       struct obd_conn conn; 
+       int rc;
+
+       ENTRY;
+       
+       conn.oc_id = req->rq_req.ost->connid;
+       conn.oc_dev = ost->ost_tgt;
+
+       rc = ost_pack_rep(NULL, 0, NULL, 0, &req->rq_rephdr, &req->rq_rep.ost,
+                         &req->rq_replen, &req->rq_repbuf); 
+       if (rc) { 
+               CERROR("cannot pack reply\n"); 
+               return rc;
+       }
+
+       memcpy(&req->rq_rep.ost->oa, &req->rq_req.ost->oa, sizeof(req->rq_req.ost->oa));
+
+       req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_punch
+               (&conn, &req->rq_rep.ost->oa, 
+                req->rq_rep.ost->oa.o_size,
+                req->rq_rep.ost->oa.o_blocks); 
+
+       EXIT;
+       return 0;
+}
+
 
 static int ost_setattr(struct ost_obd *ost, struct ptlrpc_request *req)
 {
@@ -451,6 +479,10 @@ int ost_handle(struct obd_device *obddev, struct ptlrpc_request *req)
                CDEBUG(D_INODE, "brw\n");
                rc = ost_brw(ost, req);
                break;
+       case OST_PUNCH:
+               CDEBUG(D_INODE, "punch\n");
+               rc = ost_punch(ost, req);
+               break;
        default:
                req->rq_status = -ENOTSUPP;
                return ost_error(obddev, req);