Whamcloud - gitweb
LU-12856 target: check FLFLAGS are valid while accessing them
[fs/lustre-release.git] / lustre / target / tgt_handler.c
index e41c59c..f80a2c7 100644 (file)
@@ -442,7 +442,8 @@ static int tgt_handle_request0(struct tgt_session_info *tsi,
 
                        req_capsule_set_size(tsi->tsi_pill, &RMF_SHORT_IO,
                                         RCL_SERVER,
-                                        (body->oa.o_flags & OBD_FL_SHORT_IO) ?
+                                        (body->oa.o_valid & OBD_MD_FLFLAGS &&
+                                         body->oa.o_flags & OBD_FL_SHORT_IO) ?
                                         remote_nb[0].rnb_len : 0);
                }
 
@@ -2243,7 +2244,8 @@ int tgt_brw_read(struct tgt_session_info *tsi)
        if (rc != 0)
                GOTO(out_lock, rc);
 
-       if (body->oa.o_flags & OBD_FL_SHORT_IO) {
+       if (body->oa.o_valid & OBD_MD_FLFLAGS &&
+           body->oa.o_flags & OBD_FL_SHORT_IO) {
                desc = NULL;
        } else {
                desc = ptlrpc_prep_bulk_exp(req, npages, ioobj_max_brw_get(ioo),
@@ -2322,7 +2324,8 @@ int tgt_brw_read(struct tgt_session_info *tsi)
        /* Check if client was evicted while we were doing i/o before touching
         * network */
        if (rc == 0) {
-               if (body->oa.o_flags & OBD_FL_SHORT_IO) {
+               if (body->oa.o_valid & OBD_MD_FLFLAGS &&
+                   body->oa.o_flags & OBD_FL_SHORT_IO) {
                        unsigned char *short_io_buf;
                        int short_io_size;
 
@@ -2343,7 +2346,8 @@ int tgt_brw_read(struct tgt_session_info *tsi)
                }
                no_reply = rc != 0;
        } else {
-               if (body->oa.o_flags & OBD_FL_SHORT_IO)
+               if (body->oa.o_valid & OBD_MD_FLFLAGS &&
+                   body->oa.o_flags & OBD_FL_SHORT_IO)
                        req_capsule_shrink(&req->rq_pill, &RMF_SHORT_IO, 0,
                                           RCL_SERVER);
        }
@@ -2593,7 +2597,8 @@ int tgt_brw_write(struct tgt_session_info *tsi)
                        objcount, ioo, remote_nb, &npages, local_nb);
        if (rc < 0)
                GOTO(out_lock, rc);
-       if (body->oa.o_flags & OBD_FL_SHORT_IO) {
+       if (body->oa.o_valid & OBD_MD_FLFLAGS &&
+           body->oa.o_flags & OBD_FL_SHORT_IO) {
                unsigned int short_io_size;
                unsigned char *short_io_buf;