diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 22:08:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-18 22:08:25 -0500 |
commit | 018cb13eb33383cbc3fb6d3a286ef32ecb816779 (patch) | |
tree | dcf098e343efa902b9de8580f3854440030e2ce2 /fs | |
parent | 00c845dbfe2e966a2efd3818e40f46e286ca1ae6 (diff) | |
parent | 96e869d85745df36e3a1bf794ce472cc2b18939b (diff) |
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()
Diffstat (limited to 'fs')
-rw-r--r-- | fs/hfsplus/catalog.c | 89 | ||||
-rw-r--r-- | fs/hfsplus/dir.c | 11 | ||||
-rw-r--r-- | fs/hfsplus/hfsplus_fs.h | 4 | ||||
-rw-r--r-- | fs/hfsplus/super.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/alloc.c | 28 | ||||
-rw-r--r-- | fs/ocfs2/alloc.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 16 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 12 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 2 | ||||
-rw-r--r-- | fs/proc/meminfo.c | 15 |
11 files changed, 133 insertions, 52 deletions
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c index 32602c667b4a..7892e6fddb66 100644 --- a/fs/hfsplus/catalog.c +++ b/fs/hfsplus/catalog.c | |||
@@ -38,21 +38,30 @@ int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1, | |||
38 | return hfsplus_strcmp(&k1->cat.name, &k2->cat.name); | 38 | return hfsplus_strcmp(&k1->cat.name, &k2->cat.name); |
39 | } | 39 | } |
40 | 40 | ||
41 | void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key, | 41 | /* Generates key for catalog file/folders record. */ |
42 | u32 parent, struct qstr *str) | 42 | int hfsplus_cat_build_key(struct super_block *sb, |
43 | hfsplus_btree_key *key, u32 parent, struct qstr *str) | ||
43 | { | 44 | { |
44 | int len; | 45 | int len, err; |
45 | 46 | ||
46 | key->cat.parent = cpu_to_be32(parent); | 47 | key->cat.parent = cpu_to_be32(parent); |
47 | if (str) { | 48 | err = hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN, |
48 | hfsplus_asc2uni(sb, &key->cat.name, HFSPLUS_MAX_STRLEN, | 49 | str->name, str->len); |
49 | str->name, str->len); | 50 | if (unlikely(err < 0)) |
50 | len = be16_to_cpu(key->cat.name.length); | 51 | return err; |
51 | } else { | 52 | |
52 | key->cat.name.length = 0; | 53 | len = be16_to_cpu(key->cat.name.length); |
53 | len = 0; | ||
54 | } | ||
55 | key->key_len = cpu_to_be16(6 + 2 * len); | 54 | key->key_len = cpu_to_be16(6 + 2 * len); |
55 | return 0; | ||
56 | } | ||
57 | |||
58 | /* Generates key for catalog thread record. */ | ||
59 | void hfsplus_cat_build_key_with_cnid(struct super_block *sb, | ||
60 | hfsplus_btree_key *key, u32 parent) | ||
61 | { | ||
62 | key->cat.parent = cpu_to_be32(parent); | ||
63 | key->cat.name.length = 0; | ||
64 | key->key_len = cpu_to_be16(6); | ||
56 | } | 65 | } |
57 | 66 | ||
58 | static void hfsplus_cat_build_key_uni(hfsplus_btree_key *key, u32 parent, | 67 | 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 | hfsplus_cat_entry *entry, int type, | 176 | hfsplus_cat_entry *entry, int type, |
168 | u32 parentid, struct qstr *str) | 177 | u32 parentid, struct qstr *str) |
169 | { | 178 | { |
179 | int err; | ||
180 | |||
170 | entry->type = cpu_to_be16(type); | 181 | entry->type = cpu_to_be16(type); |
171 | entry->thread.reserved = 0; | 182 | entry->thread.reserved = 0; |
172 | entry->thread.parentID = cpu_to_be32(parentid); | 183 | entry->thread.parentID = cpu_to_be32(parentid); |
173 | hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN, | 184 | err = hfsplus_asc2uni(sb, &entry->thread.nodeName, HFSPLUS_MAX_STRLEN, |
174 | str->name, str->len); | 185 | str->name, str->len); |
186 | if (unlikely(err < 0)) | ||
187 | return err; | ||
188 | |||
175 | return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2; | 189 | return 10 + be16_to_cpu(entry->thread.nodeName.length) * 2; |
176 | } | 190 | } |
177 | 191 | ||
@@ -183,7 +197,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid, | |||
183 | int err; | 197 | int err; |
184 | u16 type; | 198 | u16 type; |
185 | 199 | ||
186 | hfsplus_cat_build_key(sb, fd->search_key, cnid, NULL); | 200 | hfsplus_cat_build_key_with_cnid(sb, fd->search_key, cnid); |
187 | err = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry)); | 201 | err = hfs_brec_read(fd, &tmp, sizeof(hfsplus_cat_entry)); |
188 | if (err) | 202 | if (err) |
189 | return err; | 203 | return err; |
@@ -250,11 +264,16 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, | |||
250 | if (err) | 264 | if (err) |
251 | return err; | 265 | return err; |
252 | 266 | ||
253 | hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); | 267 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); |
254 | entry_size = hfsplus_fill_cat_thread(sb, &entry, | 268 | entry_size = hfsplus_fill_cat_thread(sb, &entry, |
255 | S_ISDIR(inode->i_mode) ? | 269 | S_ISDIR(inode->i_mode) ? |
256 | HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD, | 270 | HFSPLUS_FOLDER_THREAD : HFSPLUS_FILE_THREAD, |
257 | dir->i_ino, str); | 271 | dir->i_ino, str); |
272 | if (unlikely(entry_size < 0)) { | ||
273 | err = entry_size; | ||
274 | goto err2; | ||
275 | } | ||
276 | |||
258 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 277 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
259 | if (err != -ENOENT) { | 278 | if (err != -ENOENT) { |
260 | if (!err) | 279 | if (!err) |
@@ -265,7 +284,10 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, | |||
265 | if (err) | 284 | if (err) |
266 | goto err2; | 285 | goto err2; |
267 | 286 | ||
268 | hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); | 287 | err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); |
288 | if (unlikely(err)) | ||
289 | goto err1; | ||
290 | |||
269 | entry_size = hfsplus_cat_build_record(&entry, cnid, inode); | 291 | entry_size = hfsplus_cat_build_record(&entry, cnid, inode); |
270 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 292 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
271 | if (err != -ENOENT) { | 293 | if (err != -ENOENT) { |
@@ -288,7 +310,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir, | |||
288 | return 0; | 310 | return 0; |
289 | 311 | ||
290 | err1: | 312 | err1: |
291 | hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); | 313 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); |
292 | if (!hfs_brec_find(&fd, hfs_find_rec_by_key)) | 314 | if (!hfs_brec_find(&fd, hfs_find_rec_by_key)) |
293 | hfs_brec_remove(&fd); | 315 | hfs_brec_remove(&fd); |
294 | err2: | 316 | err2: |
@@ -313,7 +335,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) | |||
313 | if (!str) { | 335 | if (!str) { |
314 | int len; | 336 | int len; |
315 | 337 | ||
316 | hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); | 338 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); |
317 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 339 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
318 | if (err) | 340 | if (err) |
319 | goto out; | 341 | goto out; |
@@ -329,7 +351,9 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) | |||
329 | off + 2, len); | 351 | off + 2, len); |
330 | fd.search_key->key_len = cpu_to_be16(6 + len); | 352 | fd.search_key->key_len = cpu_to_be16(6 + len); |
331 | } else | 353 | } else |
332 | hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); | 354 | err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, str); |
355 | if (unlikely(err)) | ||
356 | goto out; | ||
333 | 357 | ||
334 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 358 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
335 | if (err) | 359 | if (err) |
@@ -360,7 +384,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str) | |||
360 | if (err) | 384 | if (err) |
361 | goto out; | 385 | goto out; |
362 | 386 | ||
363 | hfsplus_cat_build_key(sb, fd.search_key, cnid, NULL); | 387 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, cnid); |
364 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 388 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
365 | if (err) | 389 | if (err) |
366 | goto out; | 390 | goto out; |
@@ -405,7 +429,11 @@ int hfsplus_rename_cat(u32 cnid, | |||
405 | dst_fd = src_fd; | 429 | dst_fd = src_fd; |
406 | 430 | ||
407 | /* find the old dir entry and read the data */ | 431 | /* find the old dir entry and read the data */ |
408 | hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); | 432 | err = hfsplus_cat_build_key(sb, src_fd.search_key, |
433 | src_dir->i_ino, src_name); | ||
434 | if (unlikely(err)) | ||
435 | goto out; | ||
436 | |||
409 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); | 437 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); |
410 | if (err) | 438 | if (err) |
411 | goto out; | 439 | goto out; |
@@ -419,7 +447,11 @@ int hfsplus_rename_cat(u32 cnid, | |||
419 | type = be16_to_cpu(entry.type); | 447 | type = be16_to_cpu(entry.type); |
420 | 448 | ||
421 | /* create new dir entry with the data from the old entry */ | 449 | /* create new dir entry with the data from the old entry */ |
422 | hfsplus_cat_build_key(sb, dst_fd.search_key, dst_dir->i_ino, dst_name); | 450 | err = hfsplus_cat_build_key(sb, dst_fd.search_key, |
451 | dst_dir->i_ino, dst_name); | ||
452 | if (unlikely(err)) | ||
453 | goto out; | ||
454 | |||
423 | err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key); | 455 | err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key); |
424 | if (err != -ENOENT) { | 456 | if (err != -ENOENT) { |
425 | if (!err) | 457 | if (!err) |
@@ -436,7 +468,11 @@ int hfsplus_rename_cat(u32 cnid, | |||
436 | dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC; | 468 | dst_dir->i_mtime = dst_dir->i_ctime = CURRENT_TIME_SEC; |
437 | 469 | ||
438 | /* finally remove the old entry */ | 470 | /* finally remove the old entry */ |
439 | hfsplus_cat_build_key(sb, src_fd.search_key, src_dir->i_ino, src_name); | 471 | err = hfsplus_cat_build_key(sb, src_fd.search_key, |
472 | src_dir->i_ino, src_name); | ||
473 | if (unlikely(err)) | ||
474 | goto out; | ||
475 | |||
440 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); | 476 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); |
441 | if (err) | 477 | if (err) |
442 | goto out; | 478 | goto out; |
@@ -449,7 +485,7 @@ int hfsplus_rename_cat(u32 cnid, | |||
449 | src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC; | 485 | src_dir->i_mtime = src_dir->i_ctime = CURRENT_TIME_SEC; |
450 | 486 | ||
451 | /* remove old thread entry */ | 487 | /* remove old thread entry */ |
452 | hfsplus_cat_build_key(sb, src_fd.search_key, cnid, NULL); | 488 | hfsplus_cat_build_key_with_cnid(sb, src_fd.search_key, cnid); |
453 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); | 489 | err = hfs_brec_find(&src_fd, hfs_find_rec_by_key); |
454 | if (err) | 490 | if (err) |
455 | goto out; | 491 | goto out; |
@@ -459,9 +495,14 @@ int hfsplus_rename_cat(u32 cnid, | |||
459 | goto out; | 495 | goto out; |
460 | 496 | ||
461 | /* create new thread entry */ | 497 | /* create new thread entry */ |
462 | hfsplus_cat_build_key(sb, dst_fd.search_key, cnid, NULL); | 498 | hfsplus_cat_build_key_with_cnid(sb, dst_fd.search_key, cnid); |
463 | entry_size = hfsplus_fill_cat_thread(sb, &entry, type, | 499 | entry_size = hfsplus_fill_cat_thread(sb, &entry, type, |
464 | dst_dir->i_ino, dst_name); | 500 | dst_dir->i_ino, dst_name); |
501 | if (unlikely(entry_size < 0)) { | ||
502 | err = entry_size; | ||
503 | goto out; | ||
504 | } | ||
505 | |||
465 | err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key); | 506 | err = hfs_brec_find(&dst_fd, hfs_find_rec_by_key); |
466 | if (err != -ENOENT) { | 507 | if (err != -ENOENT) { |
467 | if (!err) | 508 | if (!err) |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 610a3260bef1..435bea231cc6 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -44,7 +44,10 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry, | |||
44 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); | 44 | err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); |
45 | if (err) | 45 | if (err) |
46 | return ERR_PTR(err); | 46 | return ERR_PTR(err); |
47 | hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name); | 47 | err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, |
48 | &dentry->d_name); | ||
49 | if (unlikely(err < 0)) | ||
50 | goto fail; | ||
48 | again: | 51 | again: |
49 | err = hfs_brec_read(&fd, &entry, sizeof(entry)); | 52 | err = hfs_brec_read(&fd, &entry, sizeof(entry)); |
50 | if (err) { | 53 | if (err) { |
@@ -97,9 +100,11 @@ again: | |||
97 | be32_to_cpu(entry.file.permissions.dev); | 100 | be32_to_cpu(entry.file.permissions.dev); |
98 | str.len = sprintf(name, "iNode%d", linkid); | 101 | str.len = sprintf(name, "iNode%d", linkid); |
99 | str.name = name; | 102 | str.name = name; |
100 | hfsplus_cat_build_key(sb, fd.search_key, | 103 | err = hfsplus_cat_build_key(sb, fd.search_key, |
101 | HFSPLUS_SB(sb)->hidden_dir->i_ino, | 104 | HFSPLUS_SB(sb)->hidden_dir->i_ino, |
102 | &str); | 105 | &str); |
106 | if (unlikely(err < 0)) | ||
107 | goto fail; | ||
103 | goto again; | 108 | goto again; |
104 | } | 109 | } |
105 | } else if (!dentry->d_fsdata) | 110 | } else if (!dentry->d_fsdata) |
@@ -145,7 +150,7 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) | |||
145 | err = -ENOMEM; | 150 | err = -ENOMEM; |
146 | goto out; | 151 | goto out; |
147 | } | 152 | } |
148 | hfsplus_cat_build_key(sb, fd.search_key, inode->i_ino, NULL); | 153 | hfsplus_cat_build_key_with_cnid(sb, fd.search_key, inode->i_ino); |
149 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); | 154 | err = hfs_brec_find(&fd, hfs_find_rec_by_key); |
150 | if (err) | 155 | if (err) |
151 | goto out; | 156 | goto out; |
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index eb5e059f481a..b0441d65fa54 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h | |||
@@ -443,8 +443,10 @@ int hfsplus_cat_case_cmp_key(const hfsplus_btree_key *k1, | |||
443 | const hfsplus_btree_key *k2); | 443 | const hfsplus_btree_key *k2); |
444 | int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1, | 444 | int hfsplus_cat_bin_cmp_key(const hfsplus_btree_key *k1, |
445 | const hfsplus_btree_key *k2); | 445 | const hfsplus_btree_key *k2); |
446 | void hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key, | 446 | int hfsplus_cat_build_key(struct super_block *sb, hfsplus_btree_key *key, |
447 | u32 parent, struct qstr *str); | 447 | u32 parent, struct qstr *str); |
448 | void hfsplus_cat_build_key_with_cnid(struct super_block *sb, | ||
449 | hfsplus_btree_key *key, u32 parent); | ||
448 | void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms); | 450 | void hfsplus_cat_set_perms(struct inode *inode, struct hfsplus_perm *perms); |
449 | int hfsplus_find_cat(struct super_block *sb, u32 cnid, | 451 | int hfsplus_find_cat(struct super_block *sb, u32 cnid, |
450 | struct hfs_find_data *fd); | 452 | struct hfs_find_data *fd); |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 4cf2024b87da..593af2fdcc2d 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -515,7 +515,9 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
515 | err = hfs_find_init(sbi->cat_tree, &fd); | 515 | err = hfs_find_init(sbi->cat_tree, &fd); |
516 | if (err) | 516 | if (err) |
517 | goto out_put_root; | 517 | goto out_put_root; |
518 | hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str); | 518 | err = hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str); |
519 | if (unlikely(err < 0)) | ||
520 | goto out_put_root; | ||
519 | if (!hfs_brec_read(&fd, &entry, sizeof(entry))) { | 521 | if (!hfs_brec_read(&fd, &entry, sizeof(entry))) { |
520 | hfs_find_exit(&fd); | 522 | hfs_find_exit(&fd); |
521 | if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) | 523 | if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) |
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index a93bf9892256..fcae9ef1a328 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -5662,7 +5662,7 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
5662 | struct ocfs2_extent_tree *et, | 5662 | struct ocfs2_extent_tree *et, |
5663 | u32 cpos, u32 phys_cpos, u32 len, int flags, | 5663 | u32 cpos, u32 phys_cpos, u32 len, int flags, |
5664 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 5664 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
5665 | u64 refcount_loc) | 5665 | u64 refcount_loc, bool refcount_tree_locked) |
5666 | { | 5666 | { |
5667 | int ret, credits = 0, extra_blocks = 0; | 5667 | int ret, credits = 0, extra_blocks = 0; |
5668 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | 5668 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
@@ -5676,11 +5676,13 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
5676 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | 5676 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & |
5677 | OCFS2_HAS_REFCOUNT_FL)); | 5677 | OCFS2_HAS_REFCOUNT_FL)); |
5678 | 5678 | ||
5679 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, | 5679 | if (!refcount_tree_locked) { |
5680 | &ref_tree, NULL); | 5680 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, |
5681 | if (ret) { | 5681 | &ref_tree, NULL); |
5682 | mlog_errno(ret); | 5682 | if (ret) { |
5683 | goto bail; | 5683 | mlog_errno(ret); |
5684 | goto bail; | ||
5685 | } | ||
5684 | } | 5686 | } |
5685 | 5687 | ||
5686 | ret = ocfs2_prepare_refcount_change_for_del(inode, | 5688 | ret = ocfs2_prepare_refcount_change_for_del(inode, |
@@ -7021,6 +7023,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
7021 | u64 refcount_loc = le64_to_cpu(di->i_refcount_loc); | 7023 | u64 refcount_loc = le64_to_cpu(di->i_refcount_loc); |
7022 | struct ocfs2_extent_tree et; | 7024 | struct ocfs2_extent_tree et; |
7023 | struct ocfs2_cached_dealloc_ctxt dealloc; | 7025 | struct ocfs2_cached_dealloc_ctxt dealloc; |
7026 | struct ocfs2_refcount_tree *ref_tree = NULL; | ||
7024 | 7027 | ||
7025 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); | 7028 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); |
7026 | ocfs2_init_dealloc_ctxt(&dealloc); | 7029 | ocfs2_init_dealloc_ctxt(&dealloc); |
@@ -7130,9 +7133,18 @@ start: | |||
7130 | 7133 | ||
7131 | phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, blkno); | 7134 | phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, blkno); |
7132 | 7135 | ||
7136 | if ((flags & OCFS2_EXT_REFCOUNTED) && trunc_len && !ref_tree) { | ||
7137 | status = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, | ||
7138 | &ref_tree, NULL); | ||
7139 | if (status) { | ||
7140 | mlog_errno(status); | ||
7141 | goto bail; | ||
7142 | } | ||
7143 | } | ||
7144 | |||
7133 | status = ocfs2_remove_btree_range(inode, &et, trunc_cpos, | 7145 | status = ocfs2_remove_btree_range(inode, &et, trunc_cpos, |
7134 | phys_cpos, trunc_len, flags, &dealloc, | 7146 | phys_cpos, trunc_len, flags, &dealloc, |
7135 | refcount_loc); | 7147 | refcount_loc, true); |
7136 | if (status < 0) { | 7148 | if (status < 0) { |
7137 | mlog_errno(status); | 7149 | mlog_errno(status); |
7138 | goto bail; | 7150 | goto bail; |
@@ -7147,6 +7159,8 @@ start: | |||
7147 | goto start; | 7159 | goto start; |
7148 | 7160 | ||
7149 | bail: | 7161 | bail: |
7162 | if (ref_tree) | ||
7163 | ocfs2_unlock_refcount_tree(osb, ref_tree, 1); | ||
7150 | 7164 | ||
7151 | ocfs2_schedule_truncate_log_flush(osb, 1); | 7165 | ocfs2_schedule_truncate_log_flush(osb, 1); |
7152 | 7166 | ||
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index ca381c584127..fb09b97db162 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -142,7 +142,7 @@ int ocfs2_remove_btree_range(struct inode *inode, | |||
142 | struct ocfs2_extent_tree *et, | 142 | struct ocfs2_extent_tree *et, |
143 | u32 cpos, u32 phys_cpos, u32 len, int flags, | 143 | u32 cpos, u32 phys_cpos, u32 len, int flags, |
144 | struct ocfs2_cached_dealloc_ctxt *dealloc, | 144 | struct ocfs2_cached_dealloc_ctxt *dealloc, |
145 | u64 refcount_loc); | 145 | u64 refcount_loc, bool refcount_tree_locked); |
146 | 146 | ||
147 | int ocfs2_num_free_extents(struct ocfs2_super *osb, | 147 | int ocfs2_num_free_extents(struct ocfs2_super *osb, |
148 | struct ocfs2_extent_tree *et); | 148 | struct ocfs2_extent_tree *et); |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index d9f222987f24..46d93e941f3d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -894,7 +894,7 @@ void ocfs2_unlock_and_free_pages(struct page **pages, int num_pages) | |||
894 | } | 894 | } |
895 | } | 895 | } |
896 | 896 | ||
897 | static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc) | 897 | static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc) |
898 | { | 898 | { |
899 | int i; | 899 | int i; |
900 | 900 | ||
@@ -915,7 +915,11 @@ static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc) | |||
915 | page_cache_release(wc->w_target_page); | 915 | page_cache_release(wc->w_target_page); |
916 | } | 916 | } |
917 | ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); | 917 | ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages); |
918 | } | ||
918 | 919 | ||
920 | static void ocfs2_free_write_ctxt(struct ocfs2_write_ctxt *wc) | ||
921 | { | ||
922 | ocfs2_unlock_pages(wc); | ||
919 | brelse(wc->w_di_bh); | 923 | brelse(wc->w_di_bh); |
920 | kfree(wc); | 924 | kfree(wc); |
921 | } | 925 | } |
@@ -2042,11 +2046,19 @@ out_write_size: | |||
2042 | ocfs2_update_inode_fsync_trans(handle, inode, 1); | 2046 | ocfs2_update_inode_fsync_trans(handle, inode, 1); |
2043 | ocfs2_journal_dirty(handle, wc->w_di_bh); | 2047 | ocfs2_journal_dirty(handle, wc->w_di_bh); |
2044 | 2048 | ||
2049 | /* unlock pages before dealloc since it needs acquiring j_trans_barrier | ||
2050 | * lock, or it will cause a deadlock since journal commit threads holds | ||
2051 | * this lock and will ask for the page lock when flushing the data. | ||
2052 | * put it here to preserve the unlock order. | ||
2053 | */ | ||
2054 | ocfs2_unlock_pages(wc); | ||
2055 | |||
2045 | ocfs2_commit_trans(osb, handle); | 2056 | ocfs2_commit_trans(osb, handle); |
2046 | 2057 | ||
2047 | ocfs2_run_deallocs(osb, &wc->w_dealloc); | 2058 | ocfs2_run_deallocs(osb, &wc->w_dealloc); |
2048 | 2059 | ||
2049 | ocfs2_free_write_ctxt(wc); | 2060 | brelse(wc->w_di_bh); |
2061 | kfree(wc); | ||
2050 | 2062 | ||
2051 | return copied; | 2063 | return copied; |
2052 | } | 2064 | } |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 79d56dc981bc..319e786175af 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -4479,7 +4479,7 @@ int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh) | |||
4479 | p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno); | 4479 | p_cpos = ocfs2_blocks_to_clusters(dir->i_sb, blkno); |
4480 | 4480 | ||
4481 | ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0, | 4481 | ret = ocfs2_remove_btree_range(dir, &et, cpos, p_cpos, clen, 0, |
4482 | &dealloc, 0); | 4482 | &dealloc, 0, false); |
4483 | if (ret) { | 4483 | if (ret) { |
4484 | mlog_errno(ret); | 4484 | mlog_errno(ret); |
4485 | goto out; | 4485 | goto out; |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 3689b3592042..a6944b25fd5b 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -695,14 +695,6 @@ void __dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm, | |||
695 | res->inflight_assert_workers); | 695 | res->inflight_assert_workers); |
696 | } | 696 | } |
697 | 697 | ||
698 | static void dlm_lockres_grab_inflight_worker(struct dlm_ctxt *dlm, | ||
699 | struct dlm_lock_resource *res) | ||
700 | { | ||
701 | spin_lock(&res->spinlock); | ||
702 | __dlm_lockres_grab_inflight_worker(dlm, res); | ||
703 | spin_unlock(&res->spinlock); | ||
704 | } | ||
705 | |||
706 | static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm, | 698 | static void __dlm_lockres_drop_inflight_worker(struct dlm_ctxt *dlm, |
707 | struct dlm_lock_resource *res) | 699 | struct dlm_lock_resource *res) |
708 | { | 700 | { |
@@ -1646,6 +1638,7 @@ send_response: | |||
1646 | } | 1638 | } |
1647 | mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", | 1639 | mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", |
1648 | dlm->node_num, res->lockname.len, res->lockname.name); | 1640 | dlm->node_num, res->lockname.len, res->lockname.name); |
1641 | spin_lock(&res->spinlock); | ||
1649 | ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx, | 1642 | ret = dlm_dispatch_assert_master(dlm, res, 0, request->node_idx, |
1650 | DLM_ASSERT_MASTER_MLE_CLEANUP); | 1643 | DLM_ASSERT_MASTER_MLE_CLEANUP); |
1651 | if (ret < 0) { | 1644 | if (ret < 0) { |
@@ -1653,7 +1646,8 @@ send_response: | |||
1653 | response = DLM_MASTER_RESP_ERROR; | 1646 | response = DLM_MASTER_RESP_ERROR; |
1654 | dlm_lockres_put(res); | 1647 | dlm_lockres_put(res); |
1655 | } else | 1648 | } else |
1656 | dlm_lockres_grab_inflight_worker(dlm, res); | 1649 | __dlm_lockres_grab_inflight_worker(dlm, res); |
1650 | spin_unlock(&res->spinlock); | ||
1657 | } else { | 1651 | } else { |
1658 | if (res) | 1652 | if (res) |
1659 | dlm_lockres_put(res); | 1653 | dlm_lockres_put(res); |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 69fb9f75b082..3950693dd0f6 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -1803,7 +1803,7 @@ static int ocfs2_remove_inode_range(struct inode *inode, | |||
1803 | 1803 | ||
1804 | ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos, | 1804 | ret = ocfs2_remove_btree_range(inode, &et, trunc_cpos, |
1805 | phys_cpos, trunc_len, flags, | 1805 | phys_cpos, trunc_len, flags, |
1806 | &dealloc, refcount_loc); | 1806 | &dealloc, refcount_loc, false); |
1807 | if (ret < 0) { | 1807 | if (ret < 0) { |
1808 | mlog_errno(ret); | 1808 | mlog_errno(ret); |
1809 | goto out; | 1809 | goto out; |
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index aa1eee06420f..d3ebf2e61853 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c | |||
@@ -12,6 +12,9 @@ | |||
12 | #include <linux/vmstat.h> | 12 | #include <linux/vmstat.h> |
13 | #include <linux/atomic.h> | 13 | #include <linux/atomic.h> |
14 | #include <linux/vmalloc.h> | 14 | #include <linux/vmalloc.h> |
15 | #ifdef CONFIG_CMA | ||
16 | #include <linux/cma.h> | ||
17 | #endif | ||
15 | #include <asm/page.h> | 18 | #include <asm/page.h> |
16 | #include <asm/pgtable.h> | 19 | #include <asm/pgtable.h> |
17 | #include "internal.h" | 20 | #include "internal.h" |
@@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
138 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 141 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
139 | "AnonHugePages: %8lu kB\n" | 142 | "AnonHugePages: %8lu kB\n" |
140 | #endif | 143 | #endif |
144 | #ifdef CONFIG_CMA | ||
145 | "CmaTotal: %8lu kB\n" | ||
146 | "CmaFree: %8lu kB\n" | ||
147 | #endif | ||
141 | , | 148 | , |
142 | K(i.totalram), | 149 | K(i.totalram), |
143 | K(i.freeram), | 150 | K(i.freeram), |
@@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
187 | vmi.used >> 10, | 194 | vmi.used >> 10, |
188 | vmi.largest_chunk >> 10 | 195 | vmi.largest_chunk >> 10 |
189 | #ifdef CONFIG_MEMORY_FAILURE | 196 | #ifdef CONFIG_MEMORY_FAILURE |
190 | ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10) | 197 | , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10) |
191 | #endif | 198 | #endif |
192 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 199 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
193 | ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * | 200 | , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * |
194 | HPAGE_PMD_NR) | 201 | HPAGE_PMD_NR) |
195 | #endif | 202 | #endif |
203 | #ifdef CONFIG_CMA | ||
204 | , K(totalcma_pages) | ||
205 | , K(global_page_state(NR_FREE_CMA_PAGES)) | ||
206 | #endif | ||
196 | ); | 207 | ); |
197 | 208 | ||
198 | hugetlb_report_meminfo(m); | 209 | hugetlb_report_meminfo(m); |