Re: [PATCH v2] btrfs: send: lower memory requirements in common case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 20, 2014 at 12:00:23PM +0000, Filipe David Manana wrote:
> >         } else {
> > -               if (is_vmalloc_addr(p->buf)) {
> > -                       tmp_buf = vmalloc(len);
> > -                       if (!tmp_buf)
> > -                               return -ENOMEM;
> > -                       memcpy(tmp_buf, p->buf, p->buf_len);
> > -                       vfree(p->buf);
> > -               } else {
> > -                       tmp_buf = krealloc(p->buf, len, GFP_NOFS);
> > -                       if (!tmp_buf) {
> > -                               tmp_buf = vmalloc(len);
> > -                               if (!tmp_buf)
> > -                                       return -ENOMEM;
> > -                               memcpy(tmp_buf, p->buf, p->buf_len);
> > -                               kfree(p->buf);
> > -                       }
> > -               }
> > -               p->buf = tmp_buf;
> > -               p->buf_len = len;
> > +               char *tmp;
> > +
> > +               tmp = krealloc(p->buf, len, GFP_NOFS);
> > +               if (!tmp)
> > +                       return -ENOMEM;
> > +               p->buf = tmp;
> > +               p->buf_len = ksize(p->buf);
> >         }
> > +
> > +       path_len = p->end - p->start;
> > +       old_buf_len = p->buf_len;
> 
> I think this is not correct here. old_buf_len doesn't get assigned the
> old buffer's length but instead the new length. So this assignment
> should be before the if-then-else that allocates/reallocates the path
> buffer, just like it was done previously before this change.

You're right, I'll send a fix. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux