2017-10-04 16:33:43 +00:00
|
|
|
/*
|
2010-05-17 22:18:00 +00:00
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 04:38:26 +00:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2013-03-05 01:26:55 +00:00
|
|
|
* For details, see <http://zfsonlinux.org/>.
|
2010-05-17 22:18:00 +00:00
|
|
|
*
|
|
|
|
* The SPL is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2008-05-26 04:38:26 +00:00
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 04:38:26 +00:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-17 22:18:00 +00:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 16:33:43 +00:00
|
|
|
*/
|
2008-05-26 04:38:26 +00:00
|
|
|
|
2008-03-05 00:58:54 +00:00
|
|
|
#ifndef _SPL_VMSYSTM_H
|
2018-02-07 19:49:38 +00:00
|
|
|
#define _SPL_VMSYSTM_H
|
2008-03-05 00:58:54 +00:00
|
|
|
|
2009-02-04 23:15:41 +00:00
|
|
|
#include <linux/mmzone.h>
|
2008-03-05 00:58:54 +00:00
|
|
|
#include <linux/mm.h>
|
2008-05-15 23:39:19 +00:00
|
|
|
#include <linux/swap.h>
|
2009-03-05 17:08:07 +00:00
|
|
|
#include <linux/highmem.h>
|
2014-01-06 23:08:35 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2008-03-14 00:04:01 +00:00
|
|
|
#include <sys/types.h>
|
2008-03-15 00:05:38 +00:00
|
|
|
#include <asm/uaccess.h>
|
2008-03-14 00:04:01 +00:00
|
|
|
|
2019-01-10 22:28:10 +00:00
|
|
|
#ifdef HAVE_TOTALRAM_PAGES_FUNC
|
|
|
|
#define zfs_totalram_pages totalram_pages()
|
|
|
|
#else
|
|
|
|
#define zfs_totalram_pages totalram_pages
|
|
|
|
#endif
|
|
|
|
|
2019-05-04 23:40:48 +00:00
|
|
|
#ifdef HAVE_TOTALHIGH_PAGES
|
|
|
|
#define zfs_totalhigh_pages totalhigh_pages()
|
|
|
|
#else
|
|
|
|
#define zfs_totalhigh_pages totalhigh_pages
|
|
|
|
#endif
|
|
|
|
|
2014-10-01 22:34:41 +00:00
|
|
|
#define membar_producer() smp_wmb()
|
2019-01-10 22:28:10 +00:00
|
|
|
#define physmem zfs_totalram_pages
|
2009-02-04 23:15:41 +00:00
|
|
|
|
2014-10-01 22:34:41 +00:00
|
|
|
#define xcopyin(from, to, size) copy_from_user(to, from, size)
|
|
|
|
#define xcopyout(from, to, size) copy_to_user(to, from, size)
|
2008-03-15 00:05:38 +00:00
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
copyin(const void *from, void *to, size_t len)
|
|
|
|
{
|
|
|
|
/* On error copyin routine returns -1 */
|
|
|
|
if (xcopyin(from, to, len))
|
2018-02-07 19:49:38 +00:00
|
|
|
return (-1);
|
2008-03-15 00:05:38 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (0);
|
2008-03-15 00:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
copyout(const void *from, void *to, size_t len)
|
|
|
|
{
|
|
|
|
/* On error copyout routine returns -1 */
|
|
|
|
if (xcopyout(from, to, len))
|
2018-02-07 19:49:38 +00:00
|
|
|
return (-1);
|
2008-03-15 00:05:38 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (0);
|
2008-03-15 00:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
copyinstr(const void *from, void *to, size_t len, size_t *done)
|
|
|
|
{
|
2008-04-01 17:00:06 +00:00
|
|
|
size_t rc;
|
|
|
|
|
2008-03-15 00:05:38 +00:00
|
|
|
if (len == 0)
|
2018-02-07 19:49:38 +00:00
|
|
|
return (-ENAMETOOLONG);
|
2008-03-15 00:05:38 +00:00
|
|
|
|
|
|
|
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
|
|
|
|
|
|
|
memset(to, 0, len);
|
2008-04-01 17:00:06 +00:00
|
|
|
rc = copyin(from, to, len - 1);
|
|
|
|
if (done != NULL)
|
|
|
|
*done = rc;
|
2008-03-15 00:05:38 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
return (0);
|
2008-03-15 00:05:38 +00:00
|
|
|
}
|
2008-03-12 21:33:28 +00:00
|
|
|
|
2008-03-05 00:58:54 +00:00
|
|
|
#endif /* SPL_VMSYSTM_H */
|