Skip to content

Commit 6939ace

Browse files
committed
NFSD: Fix frame size warning in svc_export_parse()
fs/nfsd/export.c: In function 'svc_export_parse': fs/nfsd/export.c:737:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=] 737 | } On my systems, svc_export_parse() has a stack frame of over 800 bytes, not 1040, but nonetheless, it could do with some reduction. When a struct svc_export is on the stack, it's a temporary structure used as an argument, and not visible as an actual exported FS. No need to reserve space for export_stats in such cases. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202310012359.YEw5IrK6-lkp@intel.com/ Cc: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 5ec3994 commit 6939ace

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

fs/nfsd/export.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,16 @@ static int export_stats_init(struct export_stats *stats)
339339

340340
static void export_stats_reset(struct export_stats *stats)
341341
{
342-
nfsd_percpu_counters_reset(stats->counter, EXP_STATS_COUNTERS_NUM);
342+
if (stats)
343+
nfsd_percpu_counters_reset(stats->counter,
344+
EXP_STATS_COUNTERS_NUM);
343345
}
344346

345347
static void export_stats_destroy(struct export_stats *stats)
346348
{
347-
nfsd_percpu_counters_destroy(stats->counter, EXP_STATS_COUNTERS_NUM);
349+
if (stats)
350+
nfsd_percpu_counters_destroy(stats->counter,
351+
EXP_STATS_COUNTERS_NUM);
348352
}
349353

350354
static void svc_export_put(struct kref *ref)
@@ -353,7 +357,8 @@ static void svc_export_put(struct kref *ref)
353357
path_put(&exp->ex_path);
354358
auth_domain_put(exp->ex_client);
355359
nfsd4_fslocs_free(&exp->ex_fslocs);
356-
export_stats_destroy(&exp->ex_stats);
360+
export_stats_destroy(exp->ex_stats);
361+
kfree(exp->ex_stats);
357362
kfree(exp->ex_uuid);
358363
kfree_rcu(exp, ex_rcu);
359364
}
@@ -767,13 +772,15 @@ static int svc_export_show(struct seq_file *m,
767772
seq_putc(m, '\t');
768773
seq_escape(m, exp->ex_client->name, " \t\n\\");
769774
if (export_stats) {
770-
seq_printf(m, "\t%lld\n", exp->ex_stats.start_time);
775+
struct percpu_counter *counter = exp->ex_stats->counter;
776+
777+
seq_printf(m, "\t%lld\n", exp->ex_stats->start_time);
771778
seq_printf(m, "\tfh_stale: %lld\n",
772-
percpu_counter_sum_positive(&exp->ex_stats.counter[EXP_STATS_FH_STALE]));
779+
percpu_counter_sum_positive(&counter[EXP_STATS_FH_STALE]));
773780
seq_printf(m, "\tio_read: %lld\n",
774-
percpu_counter_sum_positive(&exp->ex_stats.counter[EXP_STATS_IO_READ]));
781+
percpu_counter_sum_positive(&counter[EXP_STATS_IO_READ]));
775782
seq_printf(m, "\tio_write: %lld\n",
776-
percpu_counter_sum_positive(&exp->ex_stats.counter[EXP_STATS_IO_WRITE]));
783+
percpu_counter_sum_positive(&counter[EXP_STATS_IO_WRITE]));
777784
seq_putc(m, '\n');
778785
return 0;
779786
}
@@ -819,7 +826,7 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
819826
new->ex_layout_types = 0;
820827
new->ex_uuid = NULL;
821828
new->cd = item->cd;
822-
export_stats_reset(&new->ex_stats);
829+
export_stats_reset(new->ex_stats);
823830
}
824831

825832
static void export_update(struct cache_head *cnew, struct cache_head *citem)
@@ -856,7 +863,14 @@ static struct cache_head *svc_export_alloc(void)
856863
if (!i)
857864
return NULL;
858865

859-
if (export_stats_init(&i->ex_stats)) {
866+
i->ex_stats = kmalloc(sizeof(*(i->ex_stats)), GFP_KERNEL);
867+
if (!i->ex_stats) {
868+
kfree(i);
869+
return NULL;
870+
}
871+
872+
if (export_stats_init(i->ex_stats)) {
873+
kfree(i->ex_stats);
860874
kfree(i);
861875
return NULL;
862876
}

fs/nfsd/export.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ struct svc_export {
6464
struct cache_head h;
6565
struct auth_domain * ex_client;
6666
int ex_flags;
67+
int ex_fsid;
6768
struct path ex_path;
6869
kuid_t ex_anon_uid;
6970
kgid_t ex_anon_gid;
70-
int ex_fsid;
7171
unsigned char * ex_uuid; /* 16 byte fsid */
7272
struct nfsd4_fs_locations ex_fslocs;
7373
uint32_t ex_nflavors;
@@ -76,8 +76,8 @@ struct svc_export {
7676
struct nfsd4_deviceid_map *ex_devid_map;
7777
struct cache_detail *cd;
7878
struct rcu_head ex_rcu;
79-
struct export_stats ex_stats;
8079
unsigned long ex_xprtsec_modes;
80+
struct export_stats *ex_stats;
8181
};
8282

8383
/* an "export key" (expkey) maps a filehandlefragement to an

fs/nfsd/stats.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ static inline void nfsd_stats_rc_nocache_inc(void)
6161
static inline void nfsd_stats_fh_stale_inc(struct svc_export *exp)
6262
{
6363
percpu_counter_inc(&nfsdstats.counter[NFSD_STATS_FH_STALE]);
64-
if (exp)
65-
percpu_counter_inc(&exp->ex_stats.counter[EXP_STATS_FH_STALE]);
64+
if (exp && exp->ex_stats)
65+
percpu_counter_inc(&exp->ex_stats->counter[EXP_STATS_FH_STALE]);
6666
}
6767

6868
static inline void nfsd_stats_io_read_add(struct svc_export *exp, s64 amount)
6969
{
7070
percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_READ], amount);
71-
if (exp)
72-
percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_READ], amount);
71+
if (exp && exp->ex_stats)
72+
percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_READ], amount);
7373
}
7474

7575
static inline void nfsd_stats_io_write_add(struct svc_export *exp, s64 amount)
7676
{
7777
percpu_counter_add(&nfsdstats.counter[NFSD_STATS_IO_WRITE], amount);
78-
if (exp)
79-
percpu_counter_add(&exp->ex_stats.counter[EXP_STATS_IO_WRITE], amount);
78+
if (exp && exp->ex_stats)
79+
percpu_counter_add(&exp->ex_stats->counter[EXP_STATS_IO_WRITE], amount);
8080
}
8181

8282
static inline void nfsd_stats_payload_misses_inc(struct nfsd_net *nn)

0 commit comments

Comments
 (0)