Commit 018cb13e authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 00c845db 96e869d8
...@@ -17,7 +17,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com> ...@@ -17,7 +17,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com>
Al Viro <viro@ftp.linux.org.uk> Al Viro <viro@ftp.linux.org.uk>
Al Viro <viro@zenIV.linux.org.uk> Al Viro <viro@zenIV.linux.org.uk>
Andreas Herrmann <aherrman@de.ibm.com> Andreas Herrmann <aherrman@de.ibm.com>
Andrew Morton <akpm@osdl.org> Andrew Morton <akpm@linux-foundation.org>
Andrew Vasquez <andrew.vasquez@qlogic.com> Andrew Vasquez <andrew.vasquez@qlogic.com>
Andy Adamson <andros@citi.umich.edu> Andy Adamson <andros@citi.umich.edu>
Archit Taneja <archit@ti.com> Archit Taneja <archit@ti.com>
...@@ -102,6 +102,8 @@ Rudolf Marek <R.Marek@sh.cvut.cz> ...@@ -102,6 +102,8 @@ Rudolf Marek <R.Marek@sh.cvut.cz>
Rui Saraiva <rmps@joel.ist.utl.pt> Rui Saraiva <rmps@joel.ist.utl.pt>
Sachin P Sant <ssant@in.ibm.com> Sachin P Sant <ssant@in.ibm.com>
Sam Ravnborg <sam@mars.ravnborg.org> Sam Ravnborg <sam@mars.ravnborg.org>
Santosh Shilimkar <ssantosh@kernel.org>
Santosh Shilimkar <santosh.shilimkar@oracle.org>
Sascha Hauer <s.hauer@pengutronix.de> Sascha Hauer <s.hauer@pengutronix.de>
S.Çağlar Onur <caglar@pardus.org.tr> S.Çağlar Onur <caglar@pardus.org.tr>
Shiraz Hashim <shiraz.linux.kernel@gmail.com> <shiraz.hashim@st.com> 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, ...@@ -38,21 +38,30 @@ int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
return hfsplus_strcmp(&k1->cat.name, &k2->cat.name); return hfsplus_strcmp(&k1->cat.name, &k2->cat.name);
} }
void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key, /* Generates key for catalog file/folders record. */
u32 parent, struct qstr *str) 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); key->cat.parent = cpu_to_be32(parent);
if (str) { err = hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN,
hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN,
str->name, str->len); str->name, str->len);
if (unlikely(err < 0))
return err;
len = be16_to_cpu(key->cat.name.length); len = be16_to_cpu(key->cat.name.length);
} else {
key->cat.name.length = 0;
len = 0;
}
key->key_len = cpu_to_be16(6 + 2 * len); 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, 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, ...@@ -167,11 +176,16 @@ static int hfsplus_fill_cat_thread(struct super_block *sb,
hfsplus_cat_entry *entry, int type, hfsplus_cat_entry *entry, int type,
u32 parentid, struct qstr *str) u32 parentid, struct qstr *str)
{ {
int err;
entry->type = cpu_to_be16(type); entry->type = cpu_to_be16(type);
entry->thread.reserved = 0; entry->thread.reserved = 0;
entry->thread.parentID = cpu_to_be32(parentid); 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); str->name, str->len);
if (unlikely(err < 0))
return err;
return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2; return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2;
} }
...@@ -183,7 +197,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid, ...@@ -183,7 +197,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
int err; int err;
u16 type; 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)); err = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry));
if (err) if (err)
return err; return err;
...@@ -250,11 +264,16 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, ...@@ -250,11 +264,16 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
if (err) if (err)
return 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, entry_size = hfsplus_fill_cat_thread(sb, &entry,
S_ISDIR(inode->i_mode) ? S_ISDIR(inode->i_mode) ?
HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD, HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD,
dir->i_ino, str); dir->i_ino, str);
if (unlikely(entry_size < 0)) {
err = entry_size;
goto err2;
}
err = hfs_brec_find(&fd, hfs_find_rec_by_key); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err != -ENOENT) { if (err != -ENOENT) {
if (!err) if (!err)
...@@ -265,7 +284,10 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, ...@@ -265,7 +284,10 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
if (err) if (err)
goto err2; 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); entry_size = hfsplus_cat_build_record(&entry, cnid, inode);
err = hfs_brec_find(&fd, hfs_find_rec_by_key); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err != -ENOENT) { if (err != -ENOENT) {
...@@ -288,7 +310,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, ...@@ -288,7 +310,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
return 0; return 0;
err1: 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)) if (!hfs_brec_find(&fd, hfs_find_rec_by_key))
hfs_brec_remove(&fd); hfs_brec_remove(&fd);
err2: err2:
...@@ -313,7 +335,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) ...@@ -313,7 +335,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
if (!str) { if (!str) {
int len; 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); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
...@@ -329,7 +351,9 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) ...@@ -329,7 +351,9 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
off + 2, len); off + 2, len);
fd.search_key->key_len = cpu_to_be16(6 + len); fd.search_key->key_len = cpu_to_be16(6 + len);
} else } 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); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err) if (err)
...@@ -360,7 +384,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) ...@@ -360,7 +384,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
if (err) if (err)
goto out; 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); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
...@@ -405,7 +429,11 @@ int hfsplus_rename_cat(u32 cnid, ...@@ -405,7 +429,11 @@ int hfsplus_rename_cat(u32 cnid,
dst_fd = src_fd; dst_fd = src_fd;
/* find the old dir entry and read the data */ /* 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); err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
...@@ -419,7 +447,11 @@ int hfsplus_rename_cat(u32 cnid, ...@@ -419,7 +447,11 @@ int hfsplus_rename_cat(u32 cnid,
type = be16_to_cpu(entry.type); type = be16_to_cpu(entry.type);
/* create new dir entry with the data from the old entry */ /* 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); err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
if (err != -ENOENT) { if (err != -ENOENT) {
if (!err) if (!err)
...@@ -436,7 +468,11 @@ int hfsplus_rename_cat(u32 cnid, ...@@ -436,7 +468,11 @@ int hfsplus_rename_cat(u32 cnid,
dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC; dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC;
/* finally remove the old entry */ /* 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); err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
...@@ -449,7 +485,7 @@ int hfsplus_rename_cat(u32 cnid, ...@@ -449,7 +485,7 @@ int hfsplus_rename_cat(u32 cnid,
src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC; src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC;
/* remove old thread entry */ /* 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); err = hfs_brec_find(&src_fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
...@@ -459,9 +495,14 @@ int hfsplus_rename_cat(u32 cnid, ...@@ -459,9 +495,14 @@ int hfsplus_rename_cat(u32 cnid,
goto out; goto out;
/* create new thread entry */ /* 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, entry_size = hfsplus_fill_cat_thread(sb, &entry, type,
dst_dir->i_ino, dst_name); 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); err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key);
if (err != -ENOENT) { if (err != -ENOENT) {
if (!err) if (!err)
......
...@@ -44,7 +44,10 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, ...@@ -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); err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
if (err) if (err)
return ERR_PTR(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: again:
err = hfs_brec_read(&fd, &entry, sizeof(entry)); err = hfs_brec_read(&fd, &entry, sizeof(entry));
if (err) { if (err) {
...@@ -97,9 +100,11 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, ...@@ -97,9 +100,11 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
be32_to_cpu(entry.file.permissions.dev); be32_to_cpu(entry.file.permissions.dev);
str.len = sprintf(name, "iNode%d", linkid); str.len = sprintf(name, "iNode%d", linkid);
str.name = name; 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, HFSPLUS_SB(sb)->hidden_dir->i_ino,
&str); &str);
if (unlikely(err < 0))
goto fail;
goto again; goto again;
} }
} else if (!dentry->d_fsdata) } else if (!dentry->d_fsdata)
...@@ -145,7 +150,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) ...@@ -145,7 +150,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
err = -ENOMEM; err = -ENOMEM;
goto out; 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); err = hfs_brec_find(&fd, hfs_find_rec_by_key);
if (err) if (err)
goto out; goto out;
......
...@@ -443,8 +443,10 @@ int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1, ...@@ -443,8 +443,10 @@ int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1,
const hfsplus_btree_key *k2); const hfsplus_btree_key *k2);
int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1, int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1,
const hfsplus_btree_key *k2); 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); 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); void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms);
int hfsplus_find_cat(struct super_block *sb, u32 cnid, int hfsplus_find_cat(struct super_block *sb, u32 cnid,
struct hfs_find_data *fd); struct hfs_find_data *fd);
......
...@@ -515,7 +515,9 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) ...@@ -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); err = hfs_find_init(sbi->cat_tree, &fd);
if (err) if (err)
goto out_put_root; 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))) { if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
hfs_find_exit(&fd); hfs_find_exit(&fd);
if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) if (entry.type != cpu_to_be16(HFSPLUS_FOLDER))
......
...@@ -5662,7 +5662,7 @@ int ocfs2_remove_btree_range(struct inode *inode, ...@@ -5662,7 +5662,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
struct ocfs2_extent_tree *et, struct ocfs2_extent_tree *et,
u32 cpos, u32 phys_cpos, u32 len, int flags, u32 cpos, u32 phys_cpos, u32 len, int flags,
struct ocfs2_cached_dealloc_ctxt *dealloc, struct ocfs2_cached_dealloc_ctxt *dealloc,
u64 refcount_loc) u64 refcount_loc, bool refcount_tree_locked)
{ {
int ret, credits = 0, extra_blocks = 0; int ret, credits = 0, extra_blocks = 0;
u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
...@@ -5676,12 +5676,14 @@ int ocfs2_remove_btree_range(struct inode *inode, ...@@ -5676,12 +5676,14 @@ int ocfs2_remove_btree_range(struct inode *inode,
BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & BUG_ON(!(OCFS2_I(inode)->ip_dyn_features &
OCFS2_HAS_REFCOUNT_FL)); OCFS2_HAS_REFCOUNT_FL));
if (!refcount_tree_locked) {
ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
&ref_tree, NULL); &ref_tree, NULL);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
}
ret = ocfs2_prepare_refcount_change_for_del(inode, ret = ocfs2_prepare_refcount_change_for_del(inode,
refcount_loc, refcount_loc,
...@@ -7021,6 +7023,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, ...@@ -7021,6 +7023,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
u64 refcount_loc = le64_to_cpu(di->i_refcount_loc); u64 refcount_loc = le64_to_cpu(di->i_refcount_loc);
struct ocfs2_extent_tree et; struct ocfs2_extent_tree et;
struct ocfs2_cached_dealloc_ctxt dealloc; 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_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh);
ocfs2_init_dealloc_ctxt(&dealloc); ocfs2_init_dealloc_ctxt(&dealloc);
...@@ -7130,9 +7133,18 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, ...@@ -7130,9 +7133,18 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, blkno); 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, status = ocfs2_remove_btree_range(inode, &et, trunc_cpos,
phys_cpos, trunc_len, flags, &dealloc, phys_cpos, trunc_len, flags, &dealloc,
refcount_loc); refcount_loc, true);
if (status < 0) { if (status < 0) {
mlog_errno(status); mlog_errno(status);
goto bail; goto bail;
...@@ -7147,6 +7159,8 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, ...@@ -7147,6 +7159,8 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
goto start; goto start;
bail: bail:
if (ref_tree)
ocfs2_unlock_refcount_tree(osb, ref_tree, 1);
ocfs2_schedule_truncate_log_flush(osb, 1); ocfs2_schedule_truncate_log_flush(osb, 1);
......
...@@ -142,7 +142,7 @@ int ocfs2_remove_btree_range(struct inode *inode, ...@@ -142,7 +142,7 @@ int ocfs2_remove_btree_range(struct inode *inode,
struct ocfs2_extent_tree *et, struct ocfs2_extent_tree *et,
u32 cpos, u32 phys_cpos, u32 len, int flags, u32 cpos, u32 phys_cpos, u32 len, int flags,
struct ocfs2_cached_dealloc_ctxt *dealloc, 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, int ocfs2_num_free_extents(struct ocfs2_super *osb,
struct ocfs2_extent_tree *et); struct ocfs2_extent_tree *et);
......
...@@ -894,7 +894,7 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) ...@@ -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; int i;
...@@ -915,7 +915,11 @@ static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc) ...@@ -915,7 +915,11 @@ static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc)
page_cache_release(wc->w_target_page); page_cache_release(wc->w_target_page);
} }
ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); 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); brelse(wc->w_di_bh);
kfree(wc); kfree(wc);
} }
...@@ -2042,11 +2046,19 @@ int ocfs2_write_end_nolock(struct address_space *mapping, ...@@ -2042,11 +2046,19 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
ocfs2_update_inode_fsync_trans(handle, inode, 1); ocfs2_update_inode_fsync_trans(handle, inode, 1);
ocfs2_journal_dirty(handle, wc->w_di_bh); 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_commit_trans(osb, handle);
ocfs2_run_deallocs(osb, &wc->w_dealloc); ocfs2_run_deallocs(osb, &wc->w_dealloc);
ocfs2_free_write_ctxt(wc); brelse(wc->w_di_bh);
kfree(wc);
return copied; return copied;
} }
......
...@@ -4479,7 +4479,7 @@ int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh) ...@@ -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); p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno);
ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0, ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0,
&dealloc, 0); &dealloc, 0, false);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
goto out; goto out;
......
...@@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm, ...@@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm,
res->inflight_assert_workers); 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, static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm,
struct dlm_lock_resource *res) struct dlm_lock_resource *res)
{ {
...@@ -1646,6 +1638,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1646,6 +1638,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
} }
mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", mlog(0, "%u is the owner of %.*s, cleaning everyone else\n",
dlm->node_num, res->lockname.len, res->lockname.name); dlm->node_num, res->lockname.len, res->lockname.name);
spin_lock(&res->spinlock);
ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx, ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx,
DLM_ASSERT_MASTER_MLE_CLEANUP); DLM_ASSERT_MASTER_MLE_CLEANUP);
if (ret < 0) { if (ret < 0) {
...@@ -1653,7 +1646,8 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1653,7 +1646,8 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
response = DLM_MASTER_RESP_ERROR; response = DLM_MASTER_RESP_ERROR;
dlm_lockres_put(res); dlm_lockres_put(res);
} else } else
dlm_lockres_grab_inflight_worker(dlm, res); __dlm_lockres_grab_inflight_worker(dlm, res);
spin_unlock(&res->spinlock);
} else { } else {
if (res) if (res)
dlm_lockres_put(res); dlm_lockres_put(res);
......
...@@ -1803,7 +1803,7 @@ static int ocfs2_remove_inode_range(struct inode *inode, ...@@ -1803,7 +1803,7 @@ static int ocfs2_remove_inode_range(struct inode *inode,
ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos, ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos,
phys_cpos, trunc_len, flags, phys_cpos, trunc_len, flags,
&dealloc, refcount_loc); &dealloc, refcount_loc, false);
if (ret < 0) { if (ret < 0) {
mlog_errno(ret); mlog_errno(ret);
goto out; goto out;
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include <linux/vmstat.h> #include <linux/vmstat.h>
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#ifdef CONFIG_CMA
#include <linux/cma.h>
#endif
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include "internal.h" #include "internal.h"
...@@ -137,6 +140,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v) ...@@ -137,6 +140,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
#endif #endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
"AnonHugePages: %8lu kB\n" "AnonHugePages: %8lu kB\n"
#endif
#ifdef CONFIG_CMA
"CmaTotal: %8lu kB\n"
"CmaFree: %8lu kB\n"
#endif #endif
, ,
K(i.totalram), K(i.totalram),
...@@ -187,11 +194,15 @@ static int meminfo_proc_show(struct seq_file *m, void *v) ...@@ -187,11 +194,15 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
vmi.used >> 10, vmi.used >> 10,
vmi.largest_chunk >> 10 vmi.largest_chunk >> 10
#ifdef CONFIG_MEMORY_FAILURE #ifdef CONFIG_MEMORY_FAILURE
,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10) , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
#endif #endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE #ifdef CONFIG_TRANSPARENT_HUGEPAGE
,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
HPAGE_PMD_NR) HPAGE_PMD_NR)
#endif
#ifdef CONFIG_CMA
, K(totalcma_pages)
, K(global_page_state(NR_FREE_CMA_PAGES))
#endif #endif
); );
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
struct cma; struct cma;
extern unsigned long totalcma_pages;
extern phys_addr_t cma_get_base(struct cma *cma); extern phys_addr_t cma_get_base(struct cma *cma);
extern unsigned long cma_get_size(struct cma *cma); extern unsigned long cma_get_size(struct cma *cma);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/nmi.h> #include <linux/nmi.h>
#include <linux/quicklist.h> #include <linux/quicklist.h>
#include <linux/cma.h>
void show_mem(unsigned int filter) void show_mem(unsigned int filter)
{ {
...@@ -38,7 +39,12 @@ 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 RAM\n", total);
printk("%lu pages HighMem/MovableOnly\n", highmem); 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); printk("%lu pages reserved\n", reserved);
#endif
#ifdef CONFIG_QUICKLIST #ifdef CONFIG_QUICKLIST
printk("%lu pages in pagetable cache\n", printk("%lu pages in pagetable cache\n",
quicklist_total_size()); quicklist_total_size());
......
...@@ -337,6 +337,7 @@ int __init cma_declare_contiguous(phys_addr_t base, ...@@ -337,6 +337,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
if (ret) if (ret)
goto err; goto err;
totalcma_pages += (size / PAGE_SIZE);
pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M, pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
&base); &base);
return 0; return 0;
......
...@@ -2996,6 +2996,12 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -2996,6 +2996,12 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
if (set_page_dirty(fault_page)) if (set_page_dirty(fault_page))
dirtied = 1; 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; mapping = fault_page->mapping;
unlock_page(fault_page); unlock_page(fault_page);
if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) { if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) {
......
...@@ -162,12 +162,6 @@ static const struct mempolicy_operations { ...@@ -162,12 +162,6 @@ static const struct mempolicy_operations {
enum mpol_rebind_step step); enum mpol_rebind_step step);
} mpol_ops[MPOL_MAX]; } 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) static inline int mpol_store_user_nodemask(const struct mempolicy *pol)
{ {
return pol->flags & MPOL_MODE_FLAGS; return pol->flags & MPOL_MODE_FLAGS;
...@@ -202,7 +196,7 @@ static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes) ...@@ -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) static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
{ {
if (!is_valid_nodemask(nodes)) if (nodes_empty(*nodes))
return -EINVAL; return -EINVAL;
pol->v.nodes = *nodes; pol->v.nodes = *nodes;
return 0; return 0;
...@@ -234,7 +228,7 @@ static int mpol_set_nodemask(struct mempolicy *pol, ...@@ -234,7 +228,7 @@ static int mpol_set_nodemask(struct mempolicy *pol,
nodes = NULL; /* explicit local allocation */ nodes = NULL; /* explicit local allocation */
else { else {
if (pol->flags & MPOL_F_RELATIVE_NODES) if (pol->flags & MPOL_F_RELATIVE_NODES)
mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1); mpol_relative_nodemask(&nsc->mask2, nodes, &nsc->mask1);
else else
nodes_and(nsc->mask2, *nodes, nsc->mask1); nodes_and(nsc->mask2, *nodes, nsc->mask1);
......
...@@ -111,6 +111,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock); ...@@ -111,6 +111,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
unsigned long totalram_pages __read_mostly; unsigned long totalram_pages __read_mostly;
unsigned long totalreserve_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 * When calculating the number of globally allowed dirty pages, there
* is a certain number of per-zone reserves that should not be * 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) ...@@ -5586,7 +5587,7 @@ void __init mem_init_print_info(const char *str)
pr_info("Memory: %luK/%luK available " pr_info("Memory: %luK/%luK available "
"(%luK kernel code, %luK rwdata, %luK rodata, " "(%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 #ifdef CONFIG_HIGHMEM
", %luK highmem" ", %luK highmem"
#endif #endif
...@@ -5594,7 +5595,8 @@ void __init mem_init_print_info(const char *str) ...@@ -5594,7 +5595,8 @@ void __init mem_init_print_info(const char *str)
nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10), nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
codesize >> 10, datasize >> 10, rosize >> 10, codesize >> 10, datasize >> 10, rosize >> 10,
(init_data_size + init_code_size) >> 10, bss_size >> 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 #ifdef CONFIG_HIGHMEM
totalhigh_pages << (PAGE_SHIFT-10), totalhigh_pages << (PAGE_SHIFT-10),
#endif #endif
......
This diff is collapsed.
TARGETS = breakpoints TARGETS = breakpoints
TARGETS += cpu-hotplug TARGETS += cpu-hotplug
TARGETS += efivarfs TARGETS += efivarfs
TARGETS += exec
TARGETS += firmware
TARGETS += ftrace
TARGETS += kcmp TARGETS += kcmp
TARGETS += memfd TARGETS += memfd
TARGETS += memory-hotplug TARGETS += memory-hotplug
TARGETS += mqueue
TARGETS += mount TARGETS += mount
TARGETS += mqueue
TARGETS += net TARGETS += net
TARGETS += powerpc
TARGETS += ptrace TARGETS += ptrace
TARGETS += size
TARGETS += sysctl
TARGETS += timers TARGETS += timers
TARGETS += vm
TARGETS += powerpc
TARGETS += user TARGETS += user
TARGETS += sysctl TARGETS += vm
TARGETS += firmware #Please keep the TARGETS list alphabetically sorted
TARGETS += ftrace
TARGETS += exec
TARGETS += size
TARGETS_HOTPLUG = cpu-hotplug TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug TARGETS_HOTPLUG += memory-hotplug
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment