Re: [RFC 2/6] pstore: remove type argument from ramoops_get_next_prz
On Fri, Oct 26, 2018 at 7:00 PM, Joel Fernandes (Google) wrote: > Since we store the type of the prz when we initialize it, we no longer > need to pass it again in ramoops_get_next_prz since we can just use that > to setup the pstore record. So lets remove it from the argument list. > > Signed-off-by: Joel Fernandes (Google) Yes yes. I like where this is going. :) -Kees > --- > fs/pstore/ram.c | 20 +++- > 1 file changed, 7 insertions(+), 13 deletions(-) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index c7cd858adce7..cbfdf4b8e89d 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -125,9 +125,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) > > static struct persistent_ram_zone * > ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, > -u64 *id, > -enum pstore_type_id *typep, enum pstore_type_id type, > -bool update) > +u64 *id, enum pstore_type_id *typep, bool update) > { > struct persistent_ram_zone *prz; > int i = (*c)++; > @@ -147,7 +145,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], > uint *c, uint max, > if (!persistent_ram_old_size(prz)) > return NULL; > > - *typep = type; > + *typep = prz->type; > *id = i; > > return prz; > @@ -257,8 +255,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) { > prz = ramoops_get_next_prz(cxt->dprzs, >dump_read_cnt, >cxt->max_dump_cnt, >id, > - >type, > - PSTORE_TYPE_DMESG, 1); > + >type, 1); > if (!prz_ok(prz)) > continue; > header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), > @@ -274,20 +271,18 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > > if (!prz_ok(prz)) > prz = ramoops_get_next_prz(>cprz, >console_read_cnt, > - 1, >id, >type, > - PSTORE_TYPE_CONSOLE, 0); > + 1, >id, >type, 0); > > if (!prz_ok(prz)) > prz = ramoops_get_next_prz(>mprz, >pmsg_read_cnt, > - 1, >id, >type, > - PSTORE_TYPE_PMSG, 0); > + 1, >id, >type, 0); > > /* ftrace is last since it may want to dynamically allocate memory. */ > if (!prz_ok(prz)) { > if (!(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)) { > prz = ramoops_get_next_prz(cxt->fprzs, > >ftrace_read_cnt, 1, >id, > - >type, PSTORE_TYPE_FTRACE, 0); > + >type, 0); > } else { > /* > * Build a new dummy record which combines all the > @@ -306,8 +301,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > >ftrace_read_cnt, > cxt->max_ftrace_cnt, > >id, > - >type, > - PSTORE_TYPE_FTRACE, 0); > + >type, 0); > > if (!prz_ok(prz_next)) > continue; > -- > 2.19.1.568.g152ad8e336-goog > -- Kees Cook
Re: [RFC 2/6] pstore: remove type argument from ramoops_get_next_prz
On Fri, Oct 26, 2018 at 7:00 PM, Joel Fernandes (Google) wrote: > Since we store the type of the prz when we initialize it, we no longer > need to pass it again in ramoops_get_next_prz since we can just use that > to setup the pstore record. So lets remove it from the argument list. > > Signed-off-by: Joel Fernandes (Google) Yes yes. I like where this is going. :) -Kees > --- > fs/pstore/ram.c | 20 +++- > 1 file changed, 7 insertions(+), 13 deletions(-) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index c7cd858adce7..cbfdf4b8e89d 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -125,9 +125,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) > > static struct persistent_ram_zone * > ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, > -u64 *id, > -enum pstore_type_id *typep, enum pstore_type_id type, > -bool update) > +u64 *id, enum pstore_type_id *typep, bool update) > { > struct persistent_ram_zone *prz; > int i = (*c)++; > @@ -147,7 +145,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], > uint *c, uint max, > if (!persistent_ram_old_size(prz)) > return NULL; > > - *typep = type; > + *typep = prz->type; > *id = i; > > return prz; > @@ -257,8 +255,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) { > prz = ramoops_get_next_prz(cxt->dprzs, >dump_read_cnt, >cxt->max_dump_cnt, >id, > - >type, > - PSTORE_TYPE_DMESG, 1); > + >type, 1); > if (!prz_ok(prz)) > continue; > header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), > @@ -274,20 +271,18 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > > if (!prz_ok(prz)) > prz = ramoops_get_next_prz(>cprz, >console_read_cnt, > - 1, >id, >type, > - PSTORE_TYPE_CONSOLE, 0); > + 1, >id, >type, 0); > > if (!prz_ok(prz)) > prz = ramoops_get_next_prz(>mprz, >pmsg_read_cnt, > - 1, >id, >type, > - PSTORE_TYPE_PMSG, 0); > + 1, >id, >type, 0); > > /* ftrace is last since it may want to dynamically allocate memory. */ > if (!prz_ok(prz)) { > if (!(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)) { > prz = ramoops_get_next_prz(cxt->fprzs, > >ftrace_read_cnt, 1, >id, > - >type, PSTORE_TYPE_FTRACE, 0); > + >type, 0); > } else { > /* > * Build a new dummy record which combines all the > @@ -306,8 +301,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record > *record) > >ftrace_read_cnt, > cxt->max_ftrace_cnt, > >id, > - >type, > - PSTORE_TYPE_FTRACE, 0); > + >type, 0); > > if (!prz_ok(prz_next)) > continue; > -- > 2.19.1.568.g152ad8e336-goog > -- Kees Cook
[RFC 2/6] pstore: remove type argument from ramoops_get_next_prz
Since we store the type of the prz when we initialize it, we no longer need to pass it again in ramoops_get_next_prz since we can just use that to setup the pstore record. So lets remove it from the argument list. Signed-off-by: Joel Fernandes (Google) --- fs/pstore/ram.c | 20 +++- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index c7cd858adce7..cbfdf4b8e89d 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -125,9 +125,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) static struct persistent_ram_zone * ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, -u64 *id, -enum pstore_type_id *typep, enum pstore_type_id type, -bool update) +u64 *id, enum pstore_type_id *typep, bool update) { struct persistent_ram_zone *prz; int i = (*c)++; @@ -147,7 +145,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, if (!persistent_ram_old_size(prz)) return NULL; - *typep = type; + *typep = prz->type; *id = i; return prz; @@ -257,8 +255,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) { prz = ramoops_get_next_prz(cxt->dprzs, >dump_read_cnt, cxt->max_dump_cnt, >id, - >type, - PSTORE_TYPE_DMESG, 1); + >type, 1); if (!prz_ok(prz)) continue; header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), @@ -274,20 +271,18 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) if (!prz_ok(prz)) prz = ramoops_get_next_prz(>cprz, >console_read_cnt, - 1, >id, >type, - PSTORE_TYPE_CONSOLE, 0); + 1, >id, >type, 0); if (!prz_ok(prz)) prz = ramoops_get_next_prz(>mprz, >pmsg_read_cnt, - 1, >id, >type, - PSTORE_TYPE_PMSG, 0); + 1, >id, >type, 0); /* ftrace is last since it may want to dynamically allocate memory. */ if (!prz_ok(prz)) { if (!(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)) { prz = ramoops_get_next_prz(cxt->fprzs, >ftrace_read_cnt, 1, >id, - >type, PSTORE_TYPE_FTRACE, 0); + >type, 0); } else { /* * Build a new dummy record which combines all the @@ -306,8 +301,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) >ftrace_read_cnt, cxt->max_ftrace_cnt, >id, - >type, - PSTORE_TYPE_FTRACE, 0); + >type, 0); if (!prz_ok(prz_next)) continue; -- 2.19.1.568.g152ad8e336-goog
[RFC 2/6] pstore: remove type argument from ramoops_get_next_prz
Since we store the type of the prz when we initialize it, we no longer need to pass it again in ramoops_get_next_prz since we can just use that to setup the pstore record. So lets remove it from the argument list. Signed-off-by: Joel Fernandes (Google) --- fs/pstore/ram.c | 20 +++- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index c7cd858adce7..cbfdf4b8e89d 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -125,9 +125,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) static struct persistent_ram_zone * ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, -u64 *id, -enum pstore_type_id *typep, enum pstore_type_id type, -bool update) +u64 *id, enum pstore_type_id *typep, bool update) { struct persistent_ram_zone *prz; int i = (*c)++; @@ -147,7 +145,7 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, if (!persistent_ram_old_size(prz)) return NULL; - *typep = type; + *typep = prz->type; *id = i; return prz; @@ -257,8 +255,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) { prz = ramoops_get_next_prz(cxt->dprzs, >dump_read_cnt, cxt->max_dump_cnt, >id, - >type, - PSTORE_TYPE_DMESG, 1); + >type, 1); if (!prz_ok(prz)) continue; header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), @@ -274,20 +271,18 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) if (!prz_ok(prz)) prz = ramoops_get_next_prz(>cprz, >console_read_cnt, - 1, >id, >type, - PSTORE_TYPE_CONSOLE, 0); + 1, >id, >type, 0); if (!prz_ok(prz)) prz = ramoops_get_next_prz(>mprz, >pmsg_read_cnt, - 1, >id, >type, - PSTORE_TYPE_PMSG, 0); + 1, >id, >type, 0); /* ftrace is last since it may want to dynamically allocate memory. */ if (!prz_ok(prz)) { if (!(cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)) { prz = ramoops_get_next_prz(cxt->fprzs, >ftrace_read_cnt, 1, >id, - >type, PSTORE_TYPE_FTRACE, 0); + >type, 0); } else { /* * Build a new dummy record which combines all the @@ -306,8 +301,7 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) >ftrace_read_cnt, cxt->max_ftrace_cnt, >id, - >type, - PSTORE_TYPE_FTRACE, 0); + >type, 0); if (!prz_ok(prz_next)) continue; -- 2.19.1.568.g152ad8e336-goog