scst: Fix the get_user_pages() backport for kernel versions >= v4.4.168 (merge r7997 from trunk)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@8005 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-03-06 17:01:23 +00:00
parent 6112faf92f
commit aad4c7a9b7
2 changed files with 47 additions and 11 deletions
+47 -4
View File
@@ -656,19 +656,62 @@ static inline bool list_entry_in_list(const struct list_head *entry)
/* <linux/kernel.h> */
#if (!defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) || \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
#if LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(4, 4, 0) >> 8 && \
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168)
/*
* See also commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.4.168.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
int write, int force,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
return get_user_pages(current, current->mm, start, nr_pages, gup_flags,
pages, vmas);
}
#define get_user_pages get_user_pages_backport
#elif !defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
/*
* See also commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions")
* # v4.6.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
const bool write = gup_flags & FOLL_WRITE;
const bool force = 0;
WARN_ON_ONCE(gup_flags & ~FOLL_WRITE);
return get_user_pages(current, current->mm, start, nr_pages, write,
force, pages, vmas);
}
#define get_user_pages get_user_pages_backport
#elif (!defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
/*
* See also commit 768ae309a961 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.9.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
const bool write = gup_flags & FOLL_WRITE;
const bool force = 0;
WARN_ON_ONCE(gup_flags & ~FOLL_WRITE);
return get_user_pages(start, nr_pages, write, force, pages, vmas);
}
#define get_user_pages get_user_pages_backport
#endif
/* <linux/preempt.h> */
-7
View File
@@ -1274,15 +1274,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
(ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1);
down_read(&tsk->mm->mmap_sem);
#if (!defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/,
0/*don't force*/, ucmd->data_pages, NULL);
#else
rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE,
ucmd->data_pages, NULL);
#endif
up_read(&tsk->mm->mmap_sem);
/* get_user_pages() flushes dcache */