Skip to content

Commit e77a830

Browse files
committed
Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "5 patches. Subsystems affected by this patch series: coda, overlayfs, and mm (pagecache and memcg)" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: tools/cgroup/slabinfo.py: updated to work on current kernel mm/filemap: fix mapping_seek_hole_data on THP & 32-bit mm/filemap: fix find_lock_entries hang on 32-bit THP ovl: fix reference counting in ovl_mmap error path coda: fix reference counting in coda_file_mmap error path
2 parents 95838bd + 1974c45 commit e77a830

4 files changed

Lines changed: 27 additions & 29 deletions

File tree

fs/coda/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
175175
ret = call_mmap(vma->vm_file, vma);
176176

177177
if (ret) {
178-
/* if call_mmap fails, our caller will put coda_file so we
179-
* should drop the reference to the host_file that we got.
178+
/* if call_mmap fails, our caller will put host_file so we
179+
* should drop the reference to the coda_file that we got.
180180
*/
181-
fput(host_file);
181+
fput(coda_file);
182182
kfree(cvm_ops);
183183
} else {
184184
/* here we add redirects for the open/close vm_operations */

fs/overlayfs/file.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,20 +430,11 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
430430
if (WARN_ON(file != vma->vm_file))
431431
return -EIO;
432432

433-
vma->vm_file = get_file(realfile);
433+
vma_set_file(vma, realfile);
434434

435435
old_cred = ovl_override_creds(file_inode(file)->i_sb);
436436
ret = call_mmap(vma->vm_file, vma);
437437
revert_creds(old_cred);
438-
439-
if (ret) {
440-
/* Drop reference count from new vm_file value */
441-
fput(realfile);
442-
} else {
443-
/* Drop reference count from previous vm_file value */
444-
fput(file);
445-
}
446-
447438
ovl_file_accessed(file);
448439

449440
return ret;

mm/filemap.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,8 +1969,14 @@ unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
19691969
put:
19701970
put_page(page);
19711971
next:
1972-
if (!xa_is_value(page) && PageTransHuge(page))
1973-
xas_set(&xas, page->index + thp_nr_pages(page));
1972+
if (!xa_is_value(page) && PageTransHuge(page)) {
1973+
unsigned int nr_pages = thp_nr_pages(page);
1974+
1975+
/* Final THP may cross MAX_LFS_FILESIZE on 32-bit */
1976+
xas_set(&xas, page->index + nr_pages);
1977+
if (xas.xa_index < nr_pages)
1978+
break;
1979+
}
19741980
}
19751981
rcu_read_unlock();
19761982

@@ -2672,7 +2678,7 @@ loff_t mapping_seek_hole_data(struct address_space *mapping, loff_t start,
26722678
loff_t end, int whence)
26732679
{
26742680
XA_STATE(xas, &mapping->i_pages, start >> PAGE_SHIFT);
2675-
pgoff_t max = (end - 1) / PAGE_SIZE;
2681+
pgoff_t max = (end - 1) >> PAGE_SHIFT;
26762682
bool seek_data = (whence == SEEK_DATA);
26772683
struct page *page;
26782684

@@ -2681,33 +2687,34 @@ loff_t mapping_seek_hole_data(struct address_space *mapping, loff_t start,
26812687

26822688
rcu_read_lock();
26832689
while ((page = find_get_entry(&xas, max, XA_PRESENT))) {
2684-
loff_t pos = xas.xa_index * PAGE_SIZE;
2690+
loff_t pos = (u64)xas.xa_index << PAGE_SHIFT;
2691+
unsigned int seek_size;
26852692

26862693
if (start < pos) {
26872694
if (!seek_data)
26882695
goto unlock;
26892696
start = pos;
26902697
}
26912698

2692-
pos += seek_page_size(&xas, page);
2699+
seek_size = seek_page_size(&xas, page);
2700+
pos = round_up(pos + 1, seek_size);
26932701
start = page_seek_hole_data(&xas, mapping, page, start, pos,
26942702
seek_data);
26952703
if (start < pos)
26962704
goto unlock;
2705+
if (start >= end)
2706+
break;
2707+
if (seek_size > PAGE_SIZE)
2708+
xas_set(&xas, pos >> PAGE_SHIFT);
26972709
if (!xa_is_value(page))
26982710
put_page(page);
26992711
}
2700-
rcu_read_unlock();
2701-
27022712
if (seek_data)
2703-
return -ENXIO;
2704-
goto out;
2705-
2713+
start = -ENXIO;
27062714
unlock:
27072715
rcu_read_unlock();
2708-
if (!xa_is_value(page))
2716+
if (page && !xa_is_value(page))
27092717
put_page(page);
2710-
out:
27112718
if (start > end)
27122719
return end;
27132720
return start;

tools/cgroup/memcg_slabinfo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def detect_kernel_config():
128128

129129
cfg['nr_nodes'] = prog['nr_online_nodes'].value_()
130130

131-
if prog.type('struct kmem_cache').members[1][1] == 'flags':
131+
if prog.type('struct kmem_cache').members[1].name == 'flags':
132132
cfg['allocator'] = 'SLUB'
133-
elif prog.type('struct kmem_cache').members[1][1] == 'batchcount':
133+
elif prog.type('struct kmem_cache').members[1].name == 'batchcount':
134134
cfg['allocator'] = 'SLAB'
135135
else:
136136
err('Can\'t determine the slab allocator')
@@ -193,7 +193,7 @@ def main():
193193
# look over all slab pages, belonging to non-root memcgs
194194
# and look for objects belonging to the given memory cgroup
195195
for page in for_each_slab_page(prog):
196-
objcg_vec_raw = page.obj_cgroups.value_()
196+
objcg_vec_raw = page.memcg_data.value_()
197197
if objcg_vec_raw == 0:
198198
continue
199199
cache = page.slab_cache
@@ -202,7 +202,7 @@ def main():
202202
addr = cache.value_()
203203
caches[addr] = cache
204204
# clear the lowest bit to get the true obj_cgroups
205-
objcg_vec = Object(prog, page.obj_cgroups.type_,
205+
objcg_vec = Object(prog, 'struct obj_cgroup **',
206206
value=objcg_vec_raw & ~1)
207207

208208
if addr not in stats:

0 commit comments

Comments
 (0)