2017-10-04 19:33:43 +03:00
|
|
|
/*
|
2010-05-18 02:18:00 +04: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 08:38:26 +04:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
|
|
|
*
|
|
|
|
* 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 08:38:26 +04:00
|
|
|
*
|
2010-05-18 02:18:00 +04:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 08:38:26 +04: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-18 02:18:00 +04:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 19:33:43 +03:00
|
|
|
*/
|
2008-05-26 08:38:26 +04:00
|
|
|
|
2008-03-05 03:58:54 +03:00
|
|
|
#ifndef _SPL_VMSYSTM_H
|
2018-02-07 22:49:38 +03:00
|
|
|
#define _SPL_VMSYSTM_H
|
2008-03-05 03:58:54 +03:00
|
|
|
|
2009-02-05 02:15:41 +03:00
|
|
|
#include <linux/mmzone.h>
|
2008-03-05 03:58:54 +03:00
|
|
|
#include <linux/mm.h>
|
2008-05-16 03:39:19 +04:00
|
|
|
#include <linux/swap.h>
|
2009-03-05 20:08:07 +03:00
|
|
|
#include <linux/highmem.h>
|
2014-01-07 03:08:35 +04:00
|
|
|
#include <linux/vmalloc.h>
|
2008-03-14 03:04:01 +03:00
|
|
|
#include <sys/types.h>
|
2008-03-15 03:05:38 +03:00
|
|
|
#include <asm/uaccess.h>
|
2008-03-14 03:04:01 +03:00
|
|
|
|
2019-01-11 01:28:10 +03:00
|
|
|
#ifdef HAVE_TOTALRAM_PAGES_FUNC
|
|
|
|
#define zfs_totalram_pages totalram_pages()
|
|
|
|
#else
|
|
|
|
#define zfs_totalram_pages totalram_pages
|
|
|
|
#endif
|
|
|
|
|
2019-05-05 02:40:48 +03:00
|
|
|
#ifdef HAVE_TOTALHIGH_PAGES
|
|
|
|
#define zfs_totalhigh_pages totalhigh_pages()
|
|
|
|
#else
|
|
|
|
#define zfs_totalhigh_pages totalhigh_pages
|
|
|
|
#endif
|
|
|
|
|
2022-09-14 02:59:33 +03:00
|
|
|
#define membar_consumer() smp_rmb()
|
2014-10-02 02:34:41 +04:00
|
|
|
#define membar_producer() smp_wmb()
|
2022-09-14 02:59:33 +03:00
|
|
|
|
2019-01-11 01:28:10 +03:00
|
|
|
#define physmem zfs_totalram_pages
|
2009-02-05 02:15:41 +03:00
|
|
|
|
2014-10-02 02:34:41 +04: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 03:05:38 +03: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 22:49:38 +03:00
|
|
|
return (-1);
|
2008-03-15 03:05:38 +03:00
|
|
|
|
2018-02-07 22:49:38 +03:00
|
|
|
return (0);
|
2008-03-15 03:05:38 +03: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 22:49:38 +03:00
|
|
|
return (-1);
|
2008-03-15 03:05:38 +03:00
|
|
|
|
2018-02-07 22:49:38 +03:00
|
|
|
return (0);
|
2008-03-15 03:05:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ int
|
|
|
|
copyinstr(const void *from, void *to, size_t len, size_t *done)
|
|
|
|
{
|
2008-04-01 21:00:06 +04:00
|
|
|
size_t rc;
|
|
|
|
|
2008-03-15 03:05:38 +03:00
|
|
|
if (len == 0)
|
2018-02-07 22:49:38 +03:00
|
|
|
return (-ENAMETOOLONG);
|
2008-03-15 03:05:38 +03:00
|
|
|
|
|
|
|
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
|
|
|
|
|
|
|
memset(to, 0, len);
|
2008-04-01 21:00:06 +04:00
|
|
|
rc = copyin(from, to, len - 1);
|
|
|
|
if (done != NULL)
|
|
|
|
*done = rc;
|
2008-03-15 03:05:38 +03:00
|
|
|
|
2018-02-07 22:49:38 +03:00
|
|
|
return (0);
|
2008-03-15 03:05:38 +03:00
|
|
|
}
|
2008-03-13 00:33:28 +03:00
|
|
|
|
2008-03-05 03:58:54 +03:00
|
|
|
#endif /* SPL_VMSYSTM_H */
|