Whamcloud - gitweb
LU-8889 llite: replace memory allocation with ll_env usage 64/24064/2
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 9 Nov 2016 12:52:30 +0000 (15:52 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 1 Jan 2017 02:01:08 +0000 (02:01 +0000)
Replace memory allocation with ll_env usage in ll_file_read
like in other functions.

Change-Id: I44445ab80cc856f45271e0888ea2538d2a44cdeb
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/24064
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/llite/file.c

index 5748812..6f2fe92 100644 (file)
@@ -1410,15 +1410,18 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
 static ssize_t ll_file_read(struct file *file, char __user *buf, size_t count,
                            loff_t *ppos)
 {
+       struct lu_env *env;
        struct iovec   iov = { .iov_base = buf, .iov_len = count };
-        struct kiocb  *kiocb;
-        ssize_t        result;
-        ENTRY;
+       struct kiocb  *kiocb;
+       ssize_t        result;
+       __u16          refcheck;
+       ENTRY;
 
-       OBD_ALLOC_PTR(kiocb);
-       if (kiocb == NULL)
-               RETURN(-ENOMEM);
+       env = cl_env_get(&refcheck);
+       if (IS_ERR(env))
+               RETURN(PTR_ERR(env));
 
+       kiocb = &ll_env_info(env)->lti_kiocb;
         init_sync_kiocb(kiocb, file);
         kiocb->ki_pos = *ppos;
 #ifdef HAVE_KIOCB_KI_LEFT
@@ -1430,7 +1433,7 @@ static ssize_t ll_file_read(struct file *file, char __user *buf, size_t count,
        result = ll_file_aio_read(kiocb, &iov, 1, kiocb->ki_pos);
        *ppos = kiocb->ki_pos;
 
-       OBD_FREE_PTR(kiocb);
+       cl_env_put(env, &refcheck);
        RETURN(result);
 }