Merge branch 'akpm' (patches from Andrew)
Merge misc patches from Andrew Morton: "A few stragglers" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: tools/testing/selftests/Makefile: alphasort the TARGETS list mm/zsmalloc: adjust order of functions ocfs2: fix journal commit deadlock ocfs2/dlm: fix race between dispatched_work and dlm_lockres_grab_inflight_worker ocfs2: reflink: fix slow unlink for refcounted file mm/memory.c:do_shared_fault(): add comment .mailmap: Santosh Shilimkar has moved .mailmap: update akpm@osdl.org lib/show_mem.c: add cma reserved information fs/proc/meminfo.c: include cma info in proc/meminfo mm: cma: split cma-reserved in dmesg log hfsplus: fix longname handling mm/mempolicy.c: remove unnecessary is_valid_nodemask()
This commit is contained in:
commit
018cb13eb3
4
.mailmap
4
.mailmap
|
@ -17,7 +17,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com>
|
|||
Al Viro <viro@ftp.linux.org.uk>
|
||||
Al Viro <viro@zenIV.linux.org.uk>
|
||||
Andreas Herrmann <aherrman@de.ibm.com>
|
||||
Andrew Morton <akpm@osdl.org>
|
||||
Andrew Morton <akpm@linux-foundation.org>
|
||||
Andrew Vasquez <andrew.vasquez@qlogic.com>
|
||||
Andy Adamson <andros@citi.umich.edu>
|
||||
Archit Taneja <archit@ti.com>
|
||||
|
@ -102,6 +102,8 @@ Rudolf Marek <R.Marek@sh.cvut.cz>
|
|||
Rui Saraiva <rmps@joel.ist.utl.pt>
|
||||
Sachin P Sant <ssant@in.ibm.com>
|
||||
Sam Ravnborg <sam@mars.ravnborg.org>
|
||||
Santosh Shilimkar <ssantosh@kernel.org>
|
||||
Santosh Shilimkar <santosh.shilimkar@oracle.org>
|
||||
Sascha Hauer <s.hauer@pengutronix.de>
|
||||
S.Çağlar Onur <caglar@pardus.org.tr>
|
||||
Shiraz Hashim <shiraz.linux.kernel@gmail.com> <shiraz.hashim@st.com>
|
||||
|
|
|
@ -38,21 +38,30 @@ int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
|
|||
return hfsplus_strcmp(&k1->cat.name, &k2->cat.name);
|
||||
}
|
||||
|
||||
void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
|
||||
u32 parent, struct qstr *str)
|
||||
/* Generates key for catalog file/folders record. */
|
||||
int hfsplus_cat_build_key(struct super_block *sb,
|
||||
hfsplus_btree_key *key, u32 parent, struct qstr *str)
|
||||
{
|
||||
int len;
|
||||
int len, err;
|
||||
|
||||
key->cat.parent = cpu_to_be32(parent);
|
||||
if (str) {
|
||||
hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN,
|
||||
str->name, str->len);
|
||||
len = be16_to_cpu(key->cat.name.length);
|
||||
} else {
|
||||
key->cat.name.length = 0;
|
||||
len = 0;
|
||||
}
|
||||
err = hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN,
|
||||
str->name, str->len);
|
||||
if (unlikely(err < 0))
|
||||
return err;
|
||||
|
||||
len = be16_to_cpu(key->cat.name.length);
|
||||
key->key_len = cpu_to_be16(6 + 2 * len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Generates key for catalog thread record. */
|
||||
void hfsplus_cat_build_key_with_cnid(struct super_block *sb,
|
||||
hfsplus_btree_key *key, u32 parent)
|
||||
{
|
||||
key->cat.parent = cpu_to_be32(parent);
|
||||
key->cat.name.length = 0;
|
||||
key->key_len = cpu_to_be16(6);
|
||||
}
|
||||
|
||||
static void hfsplus_cat_build_key_uni(hfsplus_btree_key *key, u32 parent,
|
||||
|
@ -167,11 +176,16 @@ static int hfsplus_fill_cat_thread(struct super_block *sb,
|
|||
hfsplus_cat_entry *entry, int type,
|
||||
u32 parentid, struct qstr *str)
|
||||
{
|
||||
int err;
|
||||
|
||||
entry->type = cpu_to_be16(type);
|
||||
entry->thread.reserved = 0;
|
||||
entry->thread.parentID = cpu_to_be32(parentid);
|
||||
hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN,
|
||||
err = hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN,
|
||||
str->name, str->len);
|
||||
if (unlikely(err < 0))
|
||||
return err;
|
||||
|
||||
return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2;
|
||||
}
|
||||
|
||||
|
@ -183,7 +197,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
|
|||
int err;
|
||||
u16 type;
|
||||
|
||||
hfsplus_cat_build_key(sb, fd->search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd->search_key, cnid);
|
||||
err = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry));
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -250,11 +264,16 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
|
||||
entry_size = hfsplus_fill_cat_thread(sb, &entry,
|
||||
S_ISDIR(inode->i_mode) ?
|
||||
HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD,
|
||||
dir->i_ino, str);
|
||||
if (unlikely(entry_size < 0)) {
|
||||
err = entry_size;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err != -ENOENT) {
|
||||
if (!err)
|
||||
|
@ -265,7 +284,10 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
|
|||
if (err)
|
||||
goto err2;
|
||||
|
||||
hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
|
||||
err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
|
||||
if (unlikely(err))
|
||||
goto err1;
|
||||
|
||||
entry_size = hfsplus_cat_build_record(&entry, cnid, inode);
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err != -ENOENT) {
|
||||
|
@ -288,7 +310,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
|
|||
return 0;
|
||||
|
||||
err1:
|
||||
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
|
||||
if (!hfs_brec_find(&fd, hfs_find_rec_by_key))
|
||||
hfs_brec_remove(&fd);
|
||||
err2:
|
||||
|
@ -313,7 +335,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
|||
if (!str) {
|
||||
int len;
|
||||
|
||||
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -329,7 +351,9 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
|||
off + 2, len);
|
||||
fd.search_key->key_len = cpu_to_be16(6 + len);
|
||||
} else
|
||||
hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
|
||||
err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str);
|
||||
if (unlikely(err))
|
||||
goto out;
|
||||
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
|
@ -360,7 +384,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid);
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -405,7 +429,11 @@ int hfsplus_rename_cat(u32 cnid,
|
|||
dst_fd = src_fd;
|
||||
|
||||
/* find the old dir entry and read the data */
|
||||
hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
|
||||
err = hfsplus_cat_build_key(sb, src_fd.search_key,
|
||||
src_dir->i_ino, src_name);
|
||||
if (unlikely(err))
|
||||
goto out;
|
||||
|
||||
err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -419,7 +447,11 @@ int hfsplus_rename_cat(u32 cnid,
|
|||
type = be16_to_cpu(entry.type);
|
||||
|
||||
/* create new dir entry with the data from the old entry */
|
||||
hfsplus_cat_build_key(sb, dst_fd.search_key, dst_dir->i_ino, dst_name);
|
||||
err = hfsplus_cat_build_key(sb, dst_fd.search_key,
|
||||
dst_dir->i_ino, dst_name);
|
||||
if (unlikely(err))
|
||||
goto out;
|
||||
|
||||
err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
|
||||
if (err != -ENOENT) {
|
||||
if (!err)
|
||||
|
@ -436,7 +468,11 @@ int hfsplus_rename_cat(u32 cnid,
|
|||
dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC;
|
||||
|
||||
/* finally remove the old entry */
|
||||
hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name);
|
||||
err = hfsplus_cat_build_key(sb, src_fd.search_key,
|
||||
src_dir->i_ino, src_name);
|
||||
if (unlikely(err))
|
||||
goto out;
|
||||
|
||||
err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -449,7 +485,7 @@ int hfsplus_rename_cat(u32 cnid,
|
|||
src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC;
|
||||
|
||||
/* remove old thread entry */
|
||||
hfsplus_cat_build_key(sb, src_fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, src_fd.search_key, cnid);
|
||||
err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
@ -459,9 +495,14 @@ int hfsplus_rename_cat(u32 cnid,
|
|||
goto out;
|
||||
|
||||
/* create new thread entry */
|
||||
hfsplus_cat_build_key(sb, dst_fd.search_key, cnid, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, dst_fd.search_key, cnid);
|
||||
entry_size = hfsplus_fill_cat_thread(sb, &entry, type,
|
||||
dst_dir->i_ino, dst_name);
|
||||
if (unlikely(entry_size < 0)) {
|
||||
err = entry_size;
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
|
||||
if (err != -ENOENT) {
|
||||
if (!err)
|
||||
|
|
|
@ -44,7 +44,10 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
|
|||
err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name);
|
||||
err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino,
|
||||
&dentry->d_name);
|
||||
if (unlikely(err < 0))
|
||||
goto fail;
|
||||
again:
|
||||
err = hfs_brec_read(&fd, &entry, sizeof(entry));
|
||||
if (err) {
|
||||
|
@ -97,9 +100,11 @@ again:
|
|||
be32_to_cpu(entry.file.permissions.dev);
|
||||
str.len = sprintf(name, "iNode%d", linkid);
|
||||
str.name = name;
|
||||
hfsplus_cat_build_key(sb, fd.search_key,
|
||||
err = hfsplus_cat_build_key(sb, fd.search_key,
|
||||
HFSPLUS_SB(sb)->hidden_dir->i_ino,
|
||||
&str);
|
||||
if (unlikely(err < 0))
|
||||
goto fail;
|
||||
goto again;
|
||||
}
|
||||
} else if (!dentry->d_fsdata)
|
||||
|
@ -145,7 +150,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
|
|||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL);
|
||||
hfsplus_cat_build_key_with_cnid(sb, fd.search_key, inode->i_ino);
|
||||
err = hfs_brec_find(&fd, hfs_find_rec_by_key);
|
||||
if (err)
|
||||
goto out;
|
||||
|
|
|
@ -443,8 +443,10 @@ int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1,
|
|||
const hfsplus_btree_key *k2);
|
||||
int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
|
||||
const hfsplus_btree_key *k2);
|
||||
void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
|
||||
int hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key,
|
||||
u32 parent, struct qstr *str);
|
||||
void hfsplus_cat_build_key_with_cnid(struct super_block *sb,
|
||||
hfsplus_btree_key *key, u32 parent);
|
||||
void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
|
||||
int hfsplus_find_cat(struct super_block *sb, u32 cnid,
|
||||
struct hfs_find_data *fd);
|
||||
|
|
|
@ -515,7 +515,9 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
|
|||
err = hfs_find_init(sbi->cat_tree, &fd);
|
||||
if (err)
|
||||
goto out_put_root;
|
||||
hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
|
||||
err = hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
|
||||
if (unlikely(err < 0))
|
||||
goto out_put_root;
|
||||
if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
|
||||
hfs_find_exit(&fd);
|
||||
if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
|
||||
|
|
|
@ -5662,7 +5662,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
|
|||
struct ocfs2_extent_tree *et,
|
||||
u32 cpos, u32 phys_cpos, u32 len, int flags,
|
||||
struct ocfs2_cached_dealloc_ctxt *dealloc,
|
||||
u64 refcount_loc)
|
||||
u64 refcount_loc, bool refcount_tree_locked)
|
||||
{
|
||||
int ret, credits = 0, extra_blocks = 0;
|
||||
u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
|
||||
|
@ -5676,11 +5676,13 @@ int ocfs2_remove_btree_range(struct inode *inode,
|
|||
BUG_ON(!(OCFS2_I(inode)->ip_dyn_features &
|
||||
OCFS2_HAS_REFCOUNT_FL));
|
||||
|
||||
ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
|
||||
&ref_tree, NULL);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto bail;
|
||||
if (!refcount_tree_locked) {
|
||||
ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
|
||||
&ref_tree, NULL);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
|
||||
ret = ocfs2_prepare_refcount_change_for_del(inode,
|
||||
|
@ -7021,6 +7023,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
|
|||
u64 refcount_loc = le64_to_cpu(di->i_refcount_loc);
|
||||
struct ocfs2_extent_tree et;
|
||||
struct ocfs2_cached_dealloc_ctxt dealloc;
|
||||
struct ocfs2_refcount_tree *ref_tree = NULL;
|
||||
|
||||
ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh);
|
||||
ocfs2_init_dealloc_ctxt(&dealloc);
|
||||
|
@ -7130,9 +7133,18 @@ start:
|
|||
|
||||
phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, blkno);
|
||||
|
||||
if ((flags & OCFS2_EXT_REFCOUNTED) && trunc_len && !ref_tree) {
|
||||
status = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
|
||||
&ref_tree, NULL);
|
||||
if (status) {
|
||||
mlog_errno(status);
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
|
||||
status = ocfs2_remove_btree_range(inode, &et, trunc_cpos,
|
||||
phys_cpos, trunc_len, flags, &dealloc,
|
||||
refcount_loc);
|
||||
refcount_loc, true);
|
||||
if (status < 0) {
|
||||
mlog_errno(status);
|
||||
goto bail;
|
||||
|
@ -7147,6 +7159,8 @@ start:
|
|||
goto start;
|
||||
|
||||
bail:
|
||||
if (ref_tree)
|
||||
ocfs2_unlock_refcount_tree(osb, ref_tree, 1);
|
||||
|
||||
ocfs2_schedule_truncate_log_flush(osb, 1);
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
|
|||
struct ocfs2_extent_tree *et,
|
||||
u32 cpos, u32 phys_cpos, u32 len, int flags,
|
||||
struct ocfs2_cached_dealloc_ctxt *dealloc,
|
||||
u64 refcount_loc);
|
||||
u64 refcount_loc, bool refcount_tree_locked);
|
||||
|
||||
int ocfs2_num_free_extents(struct ocfs2_super *osb,
|
||||
struct ocfs2_extent_tree *et);
|
||||
|
|
|
@ -894,7 +894,7 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages)
|
|||
}
|
||||
}
|
||||
|
||||
static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc)
|
||||
static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -915,7 +915,11 @@ static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc)
|
|||
page_cache_release(wc->w_target_page);
|
||||
}
|
||||
ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages);
|
||||
}
|
||||
|
||||
static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc)
|
||||
{
|
||||
ocfs2_unlock_pages(wc);
|
||||
brelse(wc->w_di_bh);
|
||||
kfree(wc);
|
||||
}
|
||||
|
@ -2042,11 +2046,19 @@ out_write_size:
|
|||
ocfs2_update_inode_fsync_trans(handle, inode, 1);
|
||||
ocfs2_journal_dirty(handle, wc->w_di_bh);
|
||||
|
||||
/* unlock pages before dealloc since it needs acquiring j_trans_barrier
|
||||
* lock, or it will cause a deadlock since journal commit threads holds
|
||||
* this lock and will ask for the page lock when flushing the data.
|
||||
* put it here to preserve the unlock order.
|
||||
*/
|
||||
ocfs2_unlock_pages(wc);
|
||||
|
||||
ocfs2_commit_trans(osb, handle);
|
||||
|
||||
ocfs2_run_deallocs(osb, &wc->w_dealloc);
|
||||
|
||||
ocfs2_free_write_ctxt(wc);
|
||||
brelse(wc->w_di_bh);
|
||||
kfree(wc);
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
|
|
@ -4479,7 +4479,7 @@ int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh)
|
|||
p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno);
|
||||
|
||||
ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0,
|
||||
&dealloc, 0);
|
||||
&dealloc, 0, false);
|
||||
if (ret) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
|
|
|
@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm,
|
|||
res->inflight_assert_workers);
|
||||
}
|
||||
|
||||
static void dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm,
|
||||
struct dlm_lock_resource *res)
|
||||
{
|
||||
spin_lock(&res->spinlock);
|
||||
__dlm_lockres_grab_inflight_worker(dlm, res);
|
||||
spin_unlock(&res->spinlock);
|
||||
}
|
||||
|
||||
static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm,
|
||||
struct dlm_lock_resource *res)
|
||||
{
|
||||
|
@ -1646,6 +1638,7 @@ send_response:
|
|||
}
|
||||
mlog(0, "%u is the owner of %.*s, cleaning everyone else\n",
|
||||
dlm->node_num, res->lockname.len, res->lockname.name);
|
||||
spin_lock(&res->spinlock);
|
||||
ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx,
|
||||
DLM_ASSERT_MASTER_MLE_CLEANUP);
|
||||
if (ret < 0) {
|
||||
|
@ -1653,7 +1646,8 @@ send_response:
|
|||
response = DLM_MASTER_RESP_ERROR;
|
||||
dlm_lockres_put(res);
|
||||
} else
|
||||
dlm_lockres_grab_inflight_worker(dlm, res);
|
||||
__dlm_lockres_grab_inflight_worker(dlm, res);
|
||||
spin_unlock(&res->spinlock);
|
||||
} else {
|
||||
if (res)
|
||||
dlm_lockres_put(res);
|
||||
|
|
|
@ -1803,7 +1803,7 @@ static int ocfs2_remove_inode_range(struct inode *inode,
|
|||
|
||||
ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos,
|
||||
phys_cpos, trunc_len, flags,
|
||||
&dealloc, refcount_loc);
|
||||
&dealloc, refcount_loc, false);
|
||||
if (ret < 0) {
|
||||
mlog_errno(ret);
|
||||
goto out;
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include <linux/vmstat.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#ifdef CONFIG_CMA
|
||||
#include <linux/cma.h>
|
||||
#endif
|
||||
#include <asm/page.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include "internal.h"
|
||||
|
@ -137,6 +140,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
|
|||
#endif
|
||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||
"AnonHugePages: %8lu kB\n"
|
||||
#endif
|
||||
#ifdef CONFIG_CMA
|
||||
"CmaTotal: %8lu kB\n"
|
||||
"CmaFree: %8lu kB\n"
|
||||
#endif
|
||||
,
|
||||
K(i.totalram),
|
||||
|
@ -187,11 +194,15 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
|
|||
vmi.used >> 10,
|
||||
vmi.largest_chunk >> 10
|
||||
#ifdef CONFIG_MEMORY_FAILURE
|
||||
,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
|
||||
, atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
|
||||
#endif
|
||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||
,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
|
||||
, K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
|
||||
HPAGE_PMD_NR)
|
||||
#endif
|
||||
#ifdef CONFIG_CMA
|
||||
, K(totalcma_pages)
|
||||
, K(global_page_state(NR_FREE_CMA_PAGES))
|
||||
#endif
|
||||
);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
struct cma;
|
||||
|
||||
extern unsigned long totalcma_pages;
|
||||
extern phys_addr_t cma_get_base(struct cma *cma);
|
||||
extern unsigned long cma_get_size(struct cma *cma);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/mm.h>
|
||||
#include <linux/nmi.h>
|
||||
#include <linux/quicklist.h>
|
||||
#include <linux/cma.h>
|
||||
|
||||
void show_mem(unsigned int filter)
|
||||
{
|
||||
|
@ -38,7 +39,12 @@ void show_mem(unsigned int filter)
|
|||
|
||||
printk("%lu pages RAM\n", total);
|
||||
printk("%lu pages HighMem/MovableOnly\n", highmem);
|
||||
#ifdef CONFIG_CMA
|
||||
printk("%lu pages reserved\n", (reserved - totalcma_pages));
|
||||
printk("%lu pages cma reserved\n", totalcma_pages);
|
||||
#else
|
||||
printk("%lu pages reserved\n", reserved);
|
||||
#endif
|
||||
#ifdef CONFIG_QUICKLIST
|
||||
printk("%lu pages in pagetable cache\n",
|
||||
quicklist_total_size());
|
||||
|
|
1
mm/cma.c
1
mm/cma.c
|
@ -337,6 +337,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
|
|||
if (ret)
|
||||
goto err;
|
||||
|
||||
totalcma_pages += (size / PAGE_SIZE);
|
||||
pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
|
||||
&base);
|
||||
return 0;
|
||||
|
|
|
@ -2996,6 +2996,12 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||
|
||||
if (set_page_dirty(fault_page))
|
||||
dirtied = 1;
|
||||
/*
|
||||
* Take a local copy of the address_space - page.mapping may be zeroed
|
||||
* by truncate after unlock_page(). The address_space itself remains
|
||||
* pinned by vma->vm_file's reference. We rely on unlock_page()'s
|
||||
* release semantics to prevent the compiler from undoing this copying.
|
||||
*/
|
||||
mapping = fault_page->mapping;
|
||||
unlock_page(fault_page);
|
||||
if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) {
|
||||
|
|
|
@ -162,12 +162,6 @@ static const struct mempolicy_operations {
|
|||
enum mpol_rebind_step step);
|
||||
} mpol_ops[MPOL_MAX];
|
||||
|
||||
/* Check that the nodemask contains at least one populated zone */
|
||||
static int is_valid_nodemask(const nodemask_t *nodemask)
|
||||
{
|
||||
return nodes_intersects(*nodemask, node_states[N_MEMORY]);
|
||||
}
|
||||
|
||||
static inline int mpol_store_user_nodemask(const struct mempolicy *pol)
|
||||
{
|
||||
return pol->flags & MPOL_MODE_FLAGS;
|
||||
|
@ -202,7 +196,7 @@ static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
|
|||
|
||||
static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
|
||||
{
|
||||
if (!is_valid_nodemask(nodes))
|
||||
if (nodes_empty(*nodes))
|
||||
return -EINVAL;
|
||||
pol->v.nodes = *nodes;
|
||||
return 0;
|
||||
|
@ -234,7 +228,7 @@ static int mpol_set_nodemask(struct mempolicy *pol,
|
|||
nodes = NULL; /* explicit local allocation */
|
||||
else {
|
||||
if (pol->flags & MPOL_F_RELATIVE_NODES)
|
||||
mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1);
|
||||
mpol_relative_nodemask(&nsc->mask2, nodes, &nsc->mask1);
|
||||
else
|
||||
nodes_and(nsc->mask2, *nodes, nsc->mask1);
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
|
|||
|
||||
unsigned long totalram_pages __read_mostly;
|
||||
unsigned long totalreserve_pages __read_mostly;
|
||||
unsigned long totalcma_pages __read_mostly;
|
||||
/*
|
||||
* When calculating the number of globally allowed dirty pages, there
|
||||
* is a certain number of per-zone reserves that should not be
|
||||
|
@ -5586,7 +5587,7 @@ void __init mem_init_print_info(const char *str)
|
|||
|
||||
pr_info("Memory: %luK/%luK available "
|
||||
"(%luK kernel code, %luK rwdata, %luK rodata, "
|
||||
"%luK init, %luK bss, %luK reserved"
|
||||
"%luK init, %luK bss, %luK reserved, %luK cma-reserved"
|
||||
#ifdef CONFIG_HIGHMEM
|
||||
", %luK highmem"
|
||||
#endif
|
||||
|
@ -5594,7 +5595,8 @@ void __init mem_init_print_info(const char *str)
|
|||
nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
|
||||
codesize >> 10, datasize >> 10, rosize >> 10,
|
||||
(init_data_size + init_code_size) >> 10, bss_size >> 10,
|
||||
(physpages - totalram_pages) << (PAGE_SHIFT-10),
|
||||
(physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
|
||||
totalcma_pages << (PAGE_SHIFT-10),
|
||||
#ifdef CONFIG_HIGHMEM
|
||||
totalhigh_pages << (PAGE_SHIFT-10),
|
||||
#endif
|
||||
|
|
448
mm/zsmalloc.c
448
mm/zsmalloc.c
|
@ -884,19 +884,6 @@ static struct notifier_block zs_cpu_nb = {
|
|||
.notifier_call = zs_cpu_notifier
|
||||
};
|
||||
|
||||
static void zs_unregister_cpu_notifier(void)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
cpu_notifier_register_begin();
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
zs_cpu_notifier(NULL, CPU_DEAD, (void *)(long)cpu);
|
||||
__unregister_cpu_notifier(&zs_cpu_nb);
|
||||
|
||||
cpu_notifier_register_done();
|
||||
}
|
||||
|
||||
static int zs_register_cpu_notifier(void)
|
||||
{
|
||||
int cpu, uninitialized_var(ret);
|
||||
|
@ -914,6 +901,19 @@ static int zs_register_cpu_notifier(void)
|
|||
return notifier_to_errno(ret);
|
||||
}
|
||||
|
||||
static void zs_unregister_cpu_notifier(void)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
cpu_notifier_register_begin();
|
||||
|
||||
for_each_online_cpu(cpu)
|
||||
zs_cpu_notifier(NULL, CPU_DEAD, (void *)(long)cpu);
|
||||
__unregister_cpu_notifier(&zs_cpu_nb);
|
||||
|
||||
cpu_notifier_register_done();
|
||||
}
|
||||
|
||||
static void init_zs_size_classes(void)
|
||||
{
|
||||
int nr;
|
||||
|
@ -925,31 +925,6 @@ static void init_zs_size_classes(void)
|
|||
zs_size_classes = nr;
|
||||
}
|
||||
|
||||
static void __exit zs_exit(void)
|
||||
{
|
||||
#ifdef CONFIG_ZPOOL
|
||||
zpool_unregister_driver(&zs_zpool_driver);
|
||||
#endif
|
||||
zs_unregister_cpu_notifier();
|
||||
}
|
||||
|
||||
static int __init zs_init(void)
|
||||
{
|
||||
int ret = zs_register_cpu_notifier();
|
||||
|
||||
if (ret) {
|
||||
zs_unregister_cpu_notifier();
|
||||
return ret;
|
||||
}
|
||||
|
||||
init_zs_size_classes();
|
||||
|
||||
#ifdef CONFIG_ZPOOL
|
||||
zpool_register_driver(&zs_zpool_driver);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int get_maxobj_per_zspage(int size, int pages_per_zspage)
|
||||
{
|
||||
return pages_per_zspage * PAGE_SIZE / size;
|
||||
|
@ -967,6 +942,202 @@ static bool can_merge(struct size_class *prev, int size, int pages_per_zspage)
|
|||
return true;
|
||||
}
|
||||
|
||||
unsigned long zs_get_total_pages(struct zs_pool *pool)
|
||||
{
|
||||
return atomic_long_read(&pool->pages_allocated);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_get_total_pages);
|
||||
|
||||
/**
|
||||
* zs_map_object - get address of allocated object from handle.
|
||||
* @pool: pool from which the object was allocated
|
||||
* @handle: handle returned from zs_malloc
|
||||
*
|
||||
* Before using an object allocated from zs_malloc, it must be mapped using
|
||||
* this function. When done with the object, it must be unmapped using
|
||||
* zs_unmap_object.
|
||||
*
|
||||
* Only one object can be mapped per cpu at a time. There is no protection
|
||||
* against nested mappings.
|
||||
*
|
||||
* This function returns with preemption and page faults disabled.
|
||||
*/
|
||||
void *zs_map_object(struct zs_pool *pool, unsigned long handle,
|
||||
enum zs_mapmode mm)
|
||||
{
|
||||
struct page *page;
|
||||
unsigned long obj_idx, off;
|
||||
|
||||
unsigned int class_idx;
|
||||
enum fullness_group fg;
|
||||
struct size_class *class;
|
||||
struct mapping_area *area;
|
||||
struct page *pages[2];
|
||||
|
||||
BUG_ON(!handle);
|
||||
|
||||
/*
|
||||
* Because we use per-cpu mapping areas shared among the
|
||||
* pools/users, we can't allow mapping in interrupt context
|
||||
* because it can corrupt another users mappings.
|
||||
*/
|
||||
BUG_ON(in_interrupt());
|
||||
|
||||
obj_handle_to_location(handle, &page, &obj_idx);
|
||||
get_zspage_mapping(get_first_page(page), &class_idx, &fg);
|
||||
class = pool->size_class[class_idx];
|
||||
off = obj_idx_to_offset(page, obj_idx, class->size);
|
||||
|
||||
area = &get_cpu_var(zs_map_area);
|
||||
area->vm_mm = mm;
|
||||
if (off + class->size <= PAGE_SIZE) {
|
||||
/* this object is contained entirely within a page */
|
||||
area->vm_addr = kmap_atomic(page);
|
||||
return area->vm_addr + off;
|
||||
}
|
||||
|
||||
/* this object spans two pages */
|
||||
pages[0] = page;
|
||||
pages[1] = get_next_page(page);
|
||||
BUG_ON(!pages[1]);
|
||||
|
||||
return __zs_map_object(area, pages, off, class->size);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_map_object);
|
||||
|
||||
void zs_unmap_object(struct zs_pool *pool, unsigned long handle)
|
||||
{
|
||||
struct page *page;
|
||||
unsigned long obj_idx, off;
|
||||
|
||||
unsigned int class_idx;
|
||||
enum fullness_group fg;
|
||||
struct size_class *class;
|
||||
struct mapping_area *area;
|
||||
|
||||
BUG_ON(!handle);
|
||||
|
||||
obj_handle_to_location(handle, &page, &obj_idx);
|
||||
get_zspage_mapping(get_first_page(page), &class_idx, &fg);
|
||||
class = pool->size_class[class_idx];
|
||||
off = obj_idx_to_offset(page, obj_idx, class->size);
|
||||
|
||||
area = this_cpu_ptr(&zs_map_area);
|
||||
if (off + class->size <= PAGE_SIZE)
|
||||
kunmap_atomic(area->vm_addr);
|
||||
else {
|
||||
struct page *pages[2];
|
||||
|
||||
pages[0] = page;
|
||||
pages[1] = get_next_page(page);
|
||||
BUG_ON(!pages[1]);
|
||||
|
||||
__zs_unmap_object(area, pages, off, class->size);
|
||||
}
|
||||
put_cpu_var(zs_map_area);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_unmap_object);
|
||||
|
||||
/**
|
||||
* zs_malloc - Allocate block of given size from pool.
|
||||
* @pool: pool to allocate from
|
||||
* @size: size of block to allocate
|
||||
*
|
||||
* On success, handle to the allocated object is returned,
|
||||
* otherwise 0.
|
||||
* Allocation requests with size > ZS_MAX_ALLOC_SIZE will fail.
|
||||
*/
|
||||
unsigned long zs_malloc(struct zs_pool *pool, size_t size)
|
||||
{
|
||||
unsigned long obj;
|
||||
struct link_free *link;
|
||||
struct size_class *class;
|
||||
void *vaddr;
|
||||
|
||||
struct page *first_page, *m_page;
|
||||
unsigned long m_objidx, m_offset;
|
||||
|
||||
if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
|
||||
return 0;
|
||||
|
||||
class = pool->size_class[get_size_class_index(size)];
|
||||
|
||||
spin_lock(&class->lock);
|
||||
first_page = find_get_zspage(class);
|
||||
|
||||
if (!first_page) {
|
||||
spin_unlock(&class->lock);
|
||||
first_page = alloc_zspage(class, pool->flags);
|
||||
if (unlikely(!first_page))
|
||||
return 0;
|
||||
|
||||
set_zspage_mapping(first_page, class->index, ZS_EMPTY);
|
||||
atomic_long_add(class->pages_per_zspage,
|
||||
&pool->pages_allocated);
|
||||
spin_lock(&class->lock);
|
||||
}
|
||||
|
||||
obj = (unsigned long)first_page->freelist;
|
||||
obj_handle_to_location(obj, &m_page, &m_objidx);
|
||||
m_offset = obj_idx_to_offset(m_page, m_objidx, class->size);
|
||||
|
||||
vaddr = kmap_atomic(m_page);
|
||||
link = (struct link_free *)vaddr + m_offset / sizeof(*link);
|
||||
first_page->freelist = link->next;
|
||||
memset(link, POISON_INUSE, sizeof(*link));
|
||||
kunmap_atomic(vaddr);
|
||||
|
||||
first_page->inuse++;
|
||||
/* Now move the zspage to another fullness group, if required */
|
||||
fix_fullness_group(pool, first_page);
|
||||
spin_unlock(&class->lock);
|
||||
|
||||
return obj;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_malloc);
|
||||
|
||||
void zs_free(struct zs_pool *pool, unsigned long obj)
|
||||
{
|
||||
struct link_free *link;
|
||||
struct page *first_page, *f_page;
|
||||
unsigned long f_objidx, f_offset;
|
||||
void *vaddr;
|
||||
|
||||
int class_idx;
|
||||
struct size_class *class;
|
||||
enum fullness_group fullness;
|
||||
|
||||
if (unlikely(!obj))
|
||||
return;
|
||||
|
||||
obj_handle_to_location(obj, &f_page, &f_objidx);
|
||||
first_page = get_first_page(f_page);
|
||||
|
||||
get_zspage_mapping(first_page, &class_idx, &fullness);
|
||||
class = pool->size_class[class_idx];
|
||||
f_offset = obj_idx_to_offset(f_page, f_objidx, class->size);
|
||||
|
||||
spin_lock(&class->lock);
|
||||
|
||||
/* Insert this object in containing zspage's freelist */
|
||||
vaddr = kmap_atomic(f_page);
|
||||
link = (struct link_free *)(vaddr + f_offset);
|
||||
link->next = first_page->freelist;
|
||||
kunmap_atomic(vaddr);
|
||||
first_page->freelist = (void *)obj;
|
||||
|
||||
first_page->inuse--;
|
||||
fullness = fix_fullness_group(pool, first_page);
|
||||
spin_unlock(&class->lock);
|
||||
|
||||
if (fullness == ZS_EMPTY) {
|
||||
atomic_long_sub(class->pages_per_zspage,
|
||||
&pool->pages_allocated);
|
||||
free_zspage(first_page);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_free);
|
||||
|
||||
/**
|
||||
* zs_create_pool - Creates an allocation pool to work from.
|
||||
* @flags: allocation flags used to allocate pool metadata
|
||||
|
@ -1075,201 +1246,30 @@ void zs_destroy_pool(struct zs_pool *pool)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(zs_destroy_pool);
|
||||
|
||||
/**
|
||||
* zs_malloc - Allocate block of given size from pool.
|
||||
* @pool: pool to allocate from
|
||||
* @size: size of block to allocate
|
||||
*
|
||||
* On success, handle to the allocated object is returned,
|
||||
* otherwise 0.
|
||||
* Allocation requests with size > ZS_MAX_ALLOC_SIZE will fail.
|
||||
*/
|
||||
unsigned long zs_malloc(struct zs_pool *pool, size_t size)
|
||||
static int __init zs_init(void)
|
||||
{
|
||||
unsigned long obj;
|
||||
struct link_free *link;
|
||||
struct size_class *class;
|
||||
void *vaddr;
|
||||
int ret = zs_register_cpu_notifier();
|
||||
|
||||
struct page *first_page, *m_page;
|
||||
unsigned long m_objidx, m_offset;
|
||||
|
||||
if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
|
||||
return 0;
|
||||
|
||||
class = pool->size_class[get_size_class_index(size)];
|
||||
|
||||
spin_lock(&class->lock);
|
||||
first_page = find_get_zspage(class);
|
||||
|
||||
if (!first_page) {
|
||||
spin_unlock(&class->lock);
|
||||
first_page = alloc_zspage(class, pool->flags);
|
||||
if (unlikely(!first_page))
|
||||
return 0;
|
||||
|
||||
set_zspage_mapping(first_page, class->index, ZS_EMPTY);
|
||||
atomic_long_add(class->pages_per_zspage,
|
||||
&pool->pages_allocated);
|
||||
spin_lock(&class->lock);
|
||||
if (ret) {
|
||||
zs_unregister_cpu_notifier();
|
||||
return ret;
|
||||
}
|
||||
|
||||
obj = (unsigned long)first_page->freelist;
|
||||
obj_handle_to_location(obj, &m_page, &m_objidx);
|
||||
m_offset = obj_idx_to_offset(m_page, m_objidx, class->size);
|
||||
init_zs_size_classes();
|
||||
|
||||
vaddr = kmap_atomic(m_page);
|
||||
link = (struct link_free *)vaddr + m_offset / sizeof(*link);
|
||||
first_page->freelist = link->next;
|
||||
memset(link, POISON_INUSE, sizeof(*link));
|
||||
kunmap_atomic(vaddr);
|
||||
|
||||
first_page->inuse++;
|
||||
/* Now move the zspage to another fullness group, if required */
|
||||
fix_fullness_group(pool, first_page);
|
||||
spin_unlock(&class->lock);
|
||||
|
||||
return obj;
|
||||
#ifdef CONFIG_ZPOOL
|
||||
zpool_register_driver(&zs_zpool_driver);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_malloc);
|
||||
|
||||
void zs_free(struct zs_pool *pool, unsigned long obj)
|
||||
static void __exit zs_exit(void)
|
||||
{
|
||||
struct link_free *link;
|
||||
struct page *first_page, *f_page;
|
||||
unsigned long f_objidx, f_offset;
|
||||
void *vaddr;
|
||||
|
||||
int class_idx;
|
||||
struct size_class *class;
|
||||
enum fullness_group fullness;
|
||||
|
||||
if (unlikely(!obj))
|
||||
return;
|
||||
|
||||
obj_handle_to_location(obj, &f_page, &f_objidx);
|
||||
first_page = get_first_page(f_page);
|
||||
|
||||
get_zspage_mapping(first_page, &class_idx, &fullness);
|
||||
class = pool->size_class[class_idx];
|
||||
f_offset = obj_idx_to_offset(f_page, f_objidx, class->size);
|
||||
|
||||
spin_lock(&class->lock);
|
||||
|
||||
/* Insert this object in containing zspage's freelist */
|
||||
vaddr = kmap_atomic(f_page);
|
||||
link = (struct link_free *)(vaddr + f_offset);
|
||||
link->next = first_page->freelist;
|
||||
kunmap_atomic(vaddr);
|
||||
first_page->freelist = (void *)obj;
|
||||
|
||||
first_page->inuse--;
|
||||
fullness = fix_fullness_group(pool, first_page);
|
||||
spin_unlock(&class->lock);
|
||||
|
||||
if (fullness == ZS_EMPTY) {
|
||||
atomic_long_sub(class->pages_per_zspage,
|
||||
&pool->pages_allocated);
|
||||
free_zspage(first_page);
|
||||
}
|
||||
#ifdef CONFIG_ZPOOL
|
||||
zpool_unregister_driver(&zs_zpool_driver);
|
||||
#endif
|
||||
zs_unregister_cpu_notifier();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_free);
|
||||
|
||||
/**
|
||||
* zs_map_object - get address of allocated object from handle.
|
||||
* @pool: pool from which the object was allocated
|
||||
* @handle: handle returned from zs_malloc
|
||||
*
|
||||
* Before using an object allocated from zs_malloc, it must be mapped using
|
||||
* this function. When done with the object, it must be unmapped using
|
||||
* zs_unmap_object.
|
||||
*
|
||||
* Only one object can be mapped per cpu at a time. There is no protection
|
||||
* against nested mappings.
|
||||
*
|
||||
* This function returns with preemption and page faults disabled.
|
||||
*/
|
||||
void *zs_map_object(struct zs_pool *pool, unsigned long handle,
|
||||
enum zs_mapmode mm)
|
||||
{
|
||||
struct page *page;
|
||||
unsigned long obj_idx, off;
|
||||
|
||||
unsigned int class_idx;
|
||||
enum fullness_group fg;
|
||||
struct size_class *class;
|
||||
struct mapping_area *area;
|
||||
struct page *pages[2];
|
||||
|
||||
BUG_ON(!handle);
|
||||
|
||||
/*
|
||||
* Because we use per-cpu mapping areas shared among the
|
||||
* pools/users, we can't allow mapping in interrupt context
|
||||
* because it can corrupt another users mappings.
|
||||
*/
|
||||
BUG_ON(in_interrupt());
|
||||
|
||||
obj_handle_to_location(handle, &page, &obj_idx);
|
||||
get_zspage_mapping(get_first_page(page), &class_idx, &fg);
|
||||
class = pool->size_class[class_idx];
|
||||
off = obj_idx_to_offset(page, obj_idx, class->size);
|
||||
|
||||
area = &get_cpu_var(zs_map_area);
|
||||
area->vm_mm = mm;
|
||||
if (off + class->size <= PAGE_SIZE) {
|
||||
/* this object is contained entirely within a page */
|
||||
area->vm_addr = kmap_atomic(page);
|
||||
return area->vm_addr + off;
|
||||
}
|
||||
|
||||
/* this object spans two pages */
|
||||
pages[0] = page;
|
||||
pages[1] = get_next_page(page);
|
||||
BUG_ON(!pages[1]);
|
||||
|
||||
return __zs_map_object(area, pages, off, class->size);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_map_object);
|
||||
|
||||
void zs_unmap_object(struct zs_pool *pool, unsigned long handle)
|
||||
{
|
||||
struct page *page;
|
||||
unsigned long obj_idx, off;
|
||||
|
||||
unsigned int class_idx;
|
||||
enum fullness_group fg;
|
||||
struct size_class *class;
|
||||
struct mapping_area *area;
|
||||
|
||||
BUG_ON(!handle);
|
||||
|
||||
obj_handle_to_location(handle, &page, &obj_idx);
|
||||
get_zspage_mapping(get_first_page(page), &class_idx, &fg);
|
||||
class = pool->size_class[class_idx];
|
||||
off = obj_idx_to_offset(page, obj_idx, class->size);
|
||||
|
||||
area = this_cpu_ptr(&zs_map_area);
|
||||
if (off + class->size <= PAGE_SIZE)
|
||||
kunmap_atomic(area->vm_addr);
|
||||
else {
|
||||
struct page *pages[2];
|
||||
|
||||
pages[0] = page;
|
||||
pages[1] = get_next_page(page);
|
||||
BUG_ON(!pages[1]);
|
||||
|
||||
__zs_unmap_object(area, pages, off, class->size);
|
||||
}
|
||||
put_cpu_var(zs_map_area);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_unmap_object);
|
||||
|
||||
unsigned long zs_get_total_pages(struct zs_pool *pool)
|
||||
{
|
||||
return atomic_long_read(&pool->pages_allocated);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(zs_get_total_pages);
|
||||
|
||||
module_init(zs_init);
|
||||
module_exit(zs_exit);
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
TARGETS = breakpoints
|
||||
TARGETS += cpu-hotplug
|
||||
TARGETS += efivarfs
|
||||
TARGETS += exec
|
||||
TARGETS += firmware
|
||||
TARGETS += ftrace
|
||||
TARGETS += kcmp
|
||||
TARGETS += memfd
|
||||
TARGETS += memory-hotplug
|
||||
TARGETS += mqueue
|
||||
TARGETS += mount
|
||||
TARGETS += mqueue
|
||||
TARGETS += net
|
||||
TARGETS += ptrace
|
||||
TARGETS += timers
|
||||
TARGETS += vm
|
||||
TARGETS += powerpc
|
||||
TARGETS += user
|
||||
TARGETS += sysctl
|
||||
TARGETS += firmware
|
||||
TARGETS += ftrace
|
||||
TARGETS += exec
|
||||
TARGETS += ptrace
|
||||
TARGETS += size
|
||||
TARGETS += sysctl
|
||||
TARGETS += timers
|
||||
TARGETS += user
|
||||
TARGETS += vm
|
||||
#Please keep the TARGETS list alphabetically sorted
|
||||
|
||||
TARGETS_HOTPLUG = cpu-hotplug
|
||||
TARGETS_HOTPLUG += memory-hotplug
|
||||
|
|
Loading…
Reference in New Issue