Skip to content

Commit 819403c

Browse files
davidhildenbrandmstsirkin
authored andcommitted
fs/proc/vmcore: move vmcore definitions out of kcore.h
These vmcore defines are not related to /proc/kcore, move them out. We'll move "struct vmcoredd_node" to vmcore.c, because it is only used internally. While "struct vmcore" is only used internally for now, we're planning on using it from inline functions in crash_dump.h next, so move it to crash_dump.h. While at it, rename "struct vmcore" to "struct vmcore_range", which is a more suitable name and will make the usage of it outside of vmcore.c clearer. Signed-off-by: David Hildenbrand <[email protected]> Message-Id: <[email protected]> Acked-by: Andrew Morton <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 8e38695 commit 819403c

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

fs/proc/vmcore.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ static u64 vmcore_size;
5353
static struct proc_dir_entry *proc_vmcore;
5454

5555
#ifdef CONFIG_PROC_VMCORE_DEVICE_DUMP
56+
struct vmcoredd_node {
57+
struct list_head list; /* List of dumps */
58+
void *buf; /* Buffer containing device's dump */
59+
unsigned int size; /* Size of the buffer */
60+
};
61+
5662
/* Device Dump list and mutex to synchronize access to list */
5763
static LIST_HEAD(vmcoredd_list);
5864

@@ -322,10 +328,10 @@ static int vmcoredd_mmap_dumps(struct vm_area_struct *vma, unsigned long dst,
322328
*/
323329
static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos)
324330
{
331+
struct vmcore_range *m = NULL;
325332
ssize_t acc = 0, tmp;
326333
size_t tsz;
327334
u64 start;
328-
struct vmcore *m = NULL;
329335

330336
if (!iov_iter_count(iter) || *fpos >= vmcore_size)
331337
return 0;
@@ -580,7 +586,7 @@ static int mmap_vmcore(struct file *file, struct vm_area_struct *vma)
580586
{
581587
size_t size = vma->vm_end - vma->vm_start;
582588
u64 start, end, len, tsz;
583-
struct vmcore *m;
589+
struct vmcore_range *m;
584590

585591
start = (u64)vma->vm_pgoff << PAGE_SHIFT;
586592
end = start + size;
@@ -703,16 +709,16 @@ static const struct proc_ops vmcore_proc_ops = {
703709
.proc_mmap = mmap_vmcore,
704710
};
705711

706-
static struct vmcore* __init get_new_element(void)
712+
static struct vmcore_range * __init get_new_element(void)
707713
{
708-
return kzalloc(sizeof(struct vmcore), GFP_KERNEL);
714+
return kzalloc(sizeof(struct vmcore_range), GFP_KERNEL);
709715
}
710716

711717
static u64 get_vmcore_size(size_t elfsz, size_t elfnotesegsz,
712718
struct list_head *vc_list)
713719
{
720+
struct vmcore_range *m;
714721
u64 size;
715-
struct vmcore *m;
716722

717723
size = elfsz + elfnotesegsz;
718724
list_for_each_entry(m, vc_list, list) {
@@ -1110,11 +1116,11 @@ static int __init process_ptload_program_headers_elf64(char *elfptr,
11101116
size_t elfnotes_sz,
11111117
struct list_head *vc_list)
11121118
{
1119+
struct vmcore_range *new;
11131120
int i;
11141121
Elf64_Ehdr *ehdr_ptr;
11151122
Elf64_Phdr *phdr_ptr;
11161123
loff_t vmcore_off;
1117-
struct vmcore *new;
11181124

11191125
ehdr_ptr = (Elf64_Ehdr *)elfptr;
11201126
phdr_ptr = (Elf64_Phdr*)(elfptr + sizeof(Elf64_Ehdr)); /* PT_NOTE hdr */
@@ -1153,11 +1159,11 @@ static int __init process_ptload_program_headers_elf32(char *elfptr,
11531159
size_t elfnotes_sz,
11541160
struct list_head *vc_list)
11551161
{
1162+
struct vmcore_range *new;
11561163
int i;
11571164
Elf32_Ehdr *ehdr_ptr;
11581165
Elf32_Phdr *phdr_ptr;
11591166
loff_t vmcore_off;
1160-
struct vmcore *new;
11611167

11621168
ehdr_ptr = (Elf32_Ehdr *)elfptr;
11631169
phdr_ptr = (Elf32_Phdr*)(elfptr + sizeof(Elf32_Ehdr)); /* PT_NOTE hdr */
@@ -1195,8 +1201,8 @@ static int __init process_ptload_program_headers_elf32(char *elfptr,
11951201
static void set_vmcore_list_offsets(size_t elfsz, size_t elfnotes_sz,
11961202
struct list_head *vc_list)
11971203
{
1204+
struct vmcore_range *m;
11981205
loff_t vmcore_off;
1199-
struct vmcore *m;
12001206

12011207
/* Skip ELF header, program headers and ELF note segment. */
12021208
vmcore_off = elfsz + elfnotes_sz;
@@ -1605,9 +1611,9 @@ void vmcore_cleanup(void)
16051611

16061612
/* clear the vmcore list. */
16071613
while (!list_empty(&vmcore_list)) {
1608-
struct vmcore *m;
1614+
struct vmcore_range *m;
16091615

1610-
m = list_first_entry(&vmcore_list, struct vmcore, list);
1616+
m = list_first_entry(&vmcore_list, struct vmcore_range, list);
16111617
list_del(&m->list);
16121618
kfree(m);
16131619
}

include/linux/crash_dump.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ struct vmcore_cb {
114114
extern void register_vmcore_cb(struct vmcore_cb *cb);
115115
extern void unregister_vmcore_cb(struct vmcore_cb *cb);
116116

117+
struct vmcore_range {
118+
struct list_head list;
119+
unsigned long long paddr;
120+
unsigned long long size;
121+
loff_t offset;
122+
};
123+
117124
#else /* !CONFIG_CRASH_DUMP */
118125
static inline bool is_kdump_kernel(void) { return false; }
119126
#endif /* CONFIG_CRASH_DUMP */

include/linux/kcore.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ struct kcore_list {
2020
int type;
2121
};
2222

23-
struct vmcore {
24-
struct list_head list;
25-
unsigned long long paddr;
26-
unsigned long long size;
27-
loff_t offset;
28-
};
29-
30-
struct vmcoredd_node {
31-
struct list_head list; /* List of dumps */
32-
void *buf; /* Buffer containing device's dump */
33-
unsigned int size; /* Size of the buffer */
34-
};
35-
3623
#ifdef CONFIG_PROC_KCORE
3724
void __init kclist_add(struct kcore_list *, void *, size_t, int type);
3825

0 commit comments

Comments
 (0)