[PATCH V2 4/5 net-next] vxlan: check rtnl_configure_link return code correctly
rtnl_configure_link is always checked if < 0 for error code. Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 14f903d09c010..1e9ab1002281c 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -3890,7 +3890,7 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, } err = rtnl_configure_link(dev, NULL); - if (err) + if (err < 0) goto unlink; if (f) { -- 2.27.0
[PATCH V2 5/5 net-next] vxlan: fix vxlan_find_sock() documentation for l3mdev
Since commit aab8cc3630e32 ("vxlan: add support for underlay in non-default VRF") vxlan_find_sock() also checks if socket is assigned to the right level 3 master device when lower device is not in the default VRF. Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 1e9ab1002281c..fa21d62aa79c9 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -190,8 +190,9 @@ static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb) return list_first_entry(>remotes, struct vxlan_rdst, list); } -/* Find VXLAN socket based on network namespace, address family and UDP port - * and enabled unshareable flags. +/* Find VXLAN socket based on network namespace, address family, UDP port, + * enabled unshareable flags and socket device binding (see l3mdev with + * non-default VRF). */ static struct vxlan_sock *vxlan_find_sock(struct net *net, sa_family_t family, __be16 port, u32 flags, int ifindex) -- 2.27.0
[PATCH V2 2/5 net-next] vxlan: add unlikely to vxlan_remcsum check
small optimization around checking as it's being done in all receptions Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 47c762f7f5b11..cc904f003f158 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1876,7 +1876,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; if (vs->flags & VXLAN_F_REMCSUM_RX) - if (!vxlan_remcsum(, skb, vs->flags)) + if (unlikely(!vxlan_remcsum(, skb, vs->flags))) goto drop; if (vxlan_collect_metadata(vs)) { -- 2.27.0
[PATCH V2 3/5 net-next] vxlan: move encapsulation warning
vxlan_xmit_one() was only called from vxlan_xmit() without rdst and info was already tested. Emit warning in that function instead Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index cc904f003f158..14f903d09c010 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2650,11 +2650,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, udp_sum = !(flags & VXLAN_F_UDP_ZERO_CSUM6_TX); label = vxlan->cfg.label; } else { - if (!info) { - WARN_ONCE(1, "%s: Missing encapsulation instructions\n", - dev->name); - goto drop; - } remote_ip.sa.sa_family = ip_tunnel_info_af(info); if (remote_ip.sa.sa_family == AF_INET) { remote_ip.sin.sin_addr.s_addr = info->key.u.ipv4.dst; @@ -2889,6 +2884,10 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) info->mode & IP_TUNNEL_INFO_TX) { vni = tunnel_id_to_key32(info->key.tun_id); } else { + if (!info) + WARN_ONCE(1, "%s: Missing encapsulation instructions\n", + dev->name); + if (info && info->mode & IP_TUNNEL_INFO_TX) vxlan_xmit_one(skb, dev, vni, NULL, false); else -- 2.27.0
[PATCH V2 1/5 net-next] vxlan: don't collect metadata if remote checksum is wrong
call vxlan_remcsum() before md filling in vxlan_rcv() Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index b9fefe27e3e89..47c762f7f5b11 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1875,6 +1875,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) !net_eq(vxlan->net, dev_net(vxlan->dev goto drop; + if (vs->flags & VXLAN_F_REMCSUM_RX) + if (!vxlan_remcsum(, skb, vs->flags)) + goto drop; + if (vxlan_collect_metadata(vs)) { struct metadata_dst *tun_dst; @@ -1891,9 +1895,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) memset(md, 0, sizeof(*md)); } - if (vs->flags & VXLAN_F_REMCSUM_RX) - if (!vxlan_remcsum(, skb, vs->flags)) - goto drop; if (vs->flags & VXLAN_F_GBP) vxlan_parse_gbp_hdr(, skb, vs->flags, md); /* Note that GBP and GPE can never be active together. This is -- 2.27.0
[PATCH V2 0/5 net-next] vxlan: clean-up
This small patchet does some clean-up on vxlan. Second version removes VXLAN_NL2FLAG macro relevant patches as suggested by Michal and David I hope to have some feedback/ACK from vxlan developers. Fabian Frederick (5): vxlan: don't collect metadata if remote checksum is wrong vxlan: add unlikely to vxlan_remcsum check vxlan: move encapsulation warning vxlan: check rtnl_configure_link return code correctly vxlan: fix vxlan_find_sock() documentation for l3mdev drivers/net/vxlan.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) -- 2.27.0
[PATCH 7/7 net-next] vxlan: fix vxlan_find_sock() documentation for l3mdev
Since commit aab8cc3630e32 ("vxlan: add support for underlay in non-default VRF") vxlan_find_sock() also checks if socket is assigned to the right level 3 master device when lower device is not in the default VRF. Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 1501a5633a97e..2c6189e988ba3 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -190,8 +190,9 @@ static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb) return list_first_entry(>remotes, struct vxlan_rdst, list); } -/* Find VXLAN socket based on network namespace, address family and UDP port - * and enabled unshareable flags. +/* Find VXLAN socket based on network namespace, address family, UDP port, + * enabled unshareable flags and socket device binding (see l3mdev with + * non-default VRF). */ static struct vxlan_sock *vxlan_find_sock(struct net *net, sa_family_t family, __be16 port, u32 flags, int ifindex) -- 2.27.0
[PATCH 6/7 net-next] vxlan: merge VXLAN_NL2FLAG use in vxlan_nl2conf()
Sort flag assignment to add readability. Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 27 --- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index e9b561b9d23e1..1501a5633a97e 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -4035,6 +4035,18 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]); VXLAN_NL2FLAG(IFLA_VXLAN_TTL_INHERIT, VXLAN_F_TTL_INHERIT, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_PROXY, VXLAN_F_PROXY, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_RSC, VXLAN_F_RSC, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L2MISS, VXLAN_F_L2MISS, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L3MISS, VXLAN_F_L3MISS, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_COLLECT_METADATA, VXLAN_F_COLLECT_METADATA, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_TX, VXLAN_F_UDP_ZERO_CSUM6_TX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_RX, VXLAN_F_UDP_ZERO_CSUM6_RX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_TX, IFLA_VXLAN_REMCSUM_TX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_RX, VXLAN_F_REMCSUM_RX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_GBP, VXLAN_F_GBP, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_GPE, VXLAN_F_GPE, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_NOPARTIAL, VXLAN_F_REMCSUM_NOPARTIAL, changelink, false); if (data[IFLA_VXLAN_LABEL]) conf->label = nla_get_be32(data[IFLA_VXLAN_LABEL]) & @@ -4054,11 +4066,6 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_AGEING]) conf->age_interval = nla_get_u32(data[IFLA_VXLAN_AGEING]); - VXLAN_NL2FLAG(IFLA_VXLAN_PROXY, VXLAN_F_PROXY, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_RSC, VXLAN_F_RSC, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_L2MISS, VXLAN_F_L2MISS, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_L3MISS, VXLAN_F_L3MISS, changelink, false); - if (data[IFLA_VXLAN_LIMIT]) { if (changelink) { NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LIMIT], @@ -4068,8 +4075,6 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]); } - VXLAN_NL2FLAG(IFLA_VXLAN_COLLECT_METADATA, VXLAN_F_COLLECT_METADATA, changelink, false); - if (data[IFLA_VXLAN_PORT_RANGE]) { if (!changelink) { const struct ifla_vxlan_port_range *p @@ -4102,14 +4107,6 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->flags |= VXLAN_F_UDP_ZERO_CSUM_TX; } - VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_TX, VXLAN_F_UDP_ZERO_CSUM6_TX, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_RX, VXLAN_F_UDP_ZERO_CSUM6_RX, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_TX, IFLA_VXLAN_REMCSUM_TX, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_RX, VXLAN_F_REMCSUM_RX, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_GBP, VXLAN_F_GBP, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_GPE, VXLAN_F_GPE, changelink, false); - VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_NOPARTIAL, VXLAN_F_REMCSUM_NOPARTIAL, changelink, false); - if (tb[IFLA_MTU]) { if (changelink) { NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_MTU], -- 2.27.0
[PATCH 5/7 net-next] vxlan: add VXLAN_NL2FLAG macro
Replace common flag assignment with a macro. This could yet be simplified with changelink/supported but it would remove clarity Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 113 +--- include/net/vxlan.h | 10 2 files changed, 23 insertions(+), 100 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 1e9ab1002281c..e9b561b9d23e1 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -4034,14 +4034,7 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_TTL]) conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]); - if (data[IFLA_VXLAN_TTL_INHERIT]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_TTL_INHERIT, - VXLAN_F_TTL_INHERIT, changelink, false, - extack); - if (err) - return err; - - } + VXLAN_NL2FLAG(IFLA_VXLAN_TTL_INHERIT, VXLAN_F_TTL_INHERIT, changelink, false); if (data[IFLA_VXLAN_LABEL]) conf->label = nla_get_be32(data[IFLA_VXLAN_LABEL]) & @@ -4061,37 +4054,10 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_AGEING]) conf->age_interval = nla_get_u32(data[IFLA_VXLAN_AGEING]); - if (data[IFLA_VXLAN_PROXY]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_PROXY, - VXLAN_F_PROXY, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_RSC]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_RSC, - VXLAN_F_RSC, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_L2MISS]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_L2MISS, - VXLAN_F_L2MISS, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_L3MISS]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_L3MISS, - VXLAN_F_L3MISS, changelink, false, - extack); - if (err) - return err; - } + VXLAN_NL2FLAG(IFLA_VXLAN_PROXY, VXLAN_F_PROXY, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_RSC, VXLAN_F_RSC, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L2MISS, VXLAN_F_L2MISS, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L3MISS, VXLAN_F_L3MISS, changelink, false); if (data[IFLA_VXLAN_LIMIT]) { if (changelink) { @@ -4102,13 +4068,7 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]); } - if (data[IFLA_VXLAN_COLLECT_METADATA]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_COLLECT_METADATA, - VXLAN_F_COLLECT_METADATA, changelink, false, - extack); - if (err) - return err; - } + VXLAN_NL2FLAG(IFLA_VXLAN_COLLECT_METADATA, VXLAN_F_COLLECT_METADATA, changelink, false); if (data[IFLA_VXLAN_PORT_RANGE]) { if (!changelink) { @@ -4142,60 +4102,13 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->flags |= VXLAN_F_UDP_ZERO_CSUM_TX; } - if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, - VXLAN_F_UDP_ZERO_CSUM6_TX, changelink, - false, extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, - VXLAN_F_UDP_ZERO_CSUM6_RX, changelink, - false, extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_REMCSUM_TX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_TX, - VXLAN_F_REMCSUM_TX, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_REMCSUM_RX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_RX, - VXLAN_F_REMCSUM_RX, changelink, false, - extack); -
[PATCH 4/7 net-next] vxlan: check rtnl_configure_link return code correctly
rtnl_configure_link is always checked if < 0 for error code. Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 14f903d09c010..1e9ab1002281c 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -3890,7 +3890,7 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, } err = rtnl_configure_link(dev, NULL); - if (err) + if (err < 0) goto unlink; if (f) { -- 2.27.0
[PATCH 3/7 net-next] vxlan: move encapsulation warning
vxlan_xmit_one() was only called from vxlan_xmit() without rdst and info was already tested. Emit warning in that function instead Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index cc904f003f158..14f903d09c010 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2650,11 +2650,6 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, udp_sum = !(flags & VXLAN_F_UDP_ZERO_CSUM6_TX); label = vxlan->cfg.label; } else { - if (!info) { - WARN_ONCE(1, "%s: Missing encapsulation instructions\n", - dev->name); - goto drop; - } remote_ip.sa.sa_family = ip_tunnel_info_af(info); if (remote_ip.sa.sa_family == AF_INET) { remote_ip.sin.sin_addr.s_addr = info->key.u.ipv4.dst; @@ -2889,6 +2884,10 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) info->mode & IP_TUNNEL_INFO_TX) { vni = tunnel_id_to_key32(info->key.tun_id); } else { + if (!info) + WARN_ONCE(1, "%s: Missing encapsulation instructions\n", + dev->name); + if (info && info->mode & IP_TUNNEL_INFO_TX) vxlan_xmit_one(skb, dev, vni, NULL, false); else -- 2.27.0
[PATCH 2/7 net-next] vxlan: add unlikely to vxlan_remcsum check
small optimization around checking as it's being done in all receptions Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 47c762f7f5b11..cc904f003f158 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1876,7 +1876,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; if (vs->flags & VXLAN_F_REMCSUM_RX) - if (!vxlan_remcsum(, skb, vs->flags)) + if (unlikely(!vxlan_remcsum(, skb, vs->flags))) goto drop; if (vxlan_collect_metadata(vs)) { -- 2.27.0
[PATCH 1/7 net-next] vxlan: don't collect metadata if remote checksum is wrong
call vxlan_remcsum() before md filling in vxlan_rcv() Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index b9fefe27e3e89..47c762f7f5b11 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -1875,6 +1875,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) !net_eq(vxlan->net, dev_net(vxlan->dev goto drop; + if (vs->flags & VXLAN_F_REMCSUM_RX) + if (!vxlan_remcsum(, skb, vs->flags)) + goto drop; + if (vxlan_collect_metadata(vs)) { struct metadata_dst *tun_dst; @@ -1891,9 +1895,6 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) memset(md, 0, sizeof(*md)); } - if (vs->flags & VXLAN_F_REMCSUM_RX) - if (!vxlan_remcsum(, skb, vs->flags)) - goto drop; if (vs->flags & VXLAN_F_GBP) vxlan_parse_gbp_hdr(, skb, vs->flags, md); /* Note that GBP and GPE can never be active together. This is -- 2.27.0
[PATCH 3/7 linux-next] coda: use SIZE() for stat
max_t expression was already defined in coda sources Signed-off-by: Fabian Frederick --- fs/coda/upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index d0d0fed..1323793 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -553,7 +553,7 @@ int venus_statfs(struct dentry *dentry, struct kstatfs *sfs) union outputArgs *outp; int insize, outsize, error; - insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs)); + insize = SIZE(statfs); UPARG(CODA_STATFS); error = coda_upcall(coda_vcp(dentry->d_sb), insize, , inp); -- 2.4.11
[PATCH 5/7 linux-next] coda: remove sysctl object from module when unused
Inspired by NFS sysctl process Signed-off-by: Fabian Frederick --- fs/coda/Makefile | 3 ++- fs/coda/coda_int.h | 10 ++ fs/coda/coda_linux.h | 4 fs/coda/sysctl.c | 11 --- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/coda/Makefile b/fs/coda/Makefile index 1bab69a..30e4e1b 100644 --- a/fs/coda/Makefile +++ b/fs/coda/Makefile @@ -5,7 +5,8 @@ obj-$(CONFIG_CODA_FS) += coda.o coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \ -coda_linux.o symlink.o pioctl.o sysctl.o +coda_linux.o symlink.o pioctl.o +coda-$(CONFIG_SYSCTL) += sysctl.o # If you want debugging output, please uncomment the following line. diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h index bb0b3e0..f82b59c 100644 --- a/fs/coda/coda_int.h +++ b/fs/coda/coda_int.h @@ -13,9 +13,19 @@ extern int coda_fake_statfs; void coda_destroy_inodecache(void); int __init coda_init_inodecache(void); int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync); + +#ifdef CONFIG_SYSCTL void coda_sysctl_init(void); void coda_sysctl_clean(void); +#else +static inline void coda_sysctl_init(void) +{ +} +static inline void coda_sysctl_clean(void) +{ +} +#endif #endif /* _CODA_INT_ */ diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index 903f2a3..4087264 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h @@ -59,10 +59,6 @@ void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); unsigned short coda_flags_to_cflags(unsigned short); -/* sysctl.h */ -void coda_sysctl_init(void); -void coda_sysctl_clean(void); - #define CODA_ALLOC(ptr, cast, size) do { \ if (size < PAGE_SIZE) \ ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index 0301d45..fda3b70 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c @@ -12,7 +12,6 @@ #include "coda_int.h" -#ifdef CONFIG_SYSCTL static struct ctl_table_header *fs_table_header; static struct ctl_table coda_table[] = { @@ -62,13 +61,3 @@ void coda_sysctl_clean(void) fs_table_header = NULL; } } - -#else -void coda_sysctl_init(void) -{ -} - -void coda_sysctl_clean(void) -{ -} -#endif -- 2.4.11
[PATCH 6/7 linux-next] coda: remove sb test in coda_fid_to_inode()
coda_fid_to_inode() is only called by coda_downcall() where sb is already being tested. Signed-off-by: Fabian Frederick --- fs/coda/cnode.c | 5 - 1 file changed, 5 deletions(-) diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index 845b5a6..c42d340 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c @@ -137,11 +137,6 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb) struct inode *inode; unsigned long hash = coda_f2i(fid); - if ( !sb ) { - pr_warn("%s: no sb!\n", __func__); - return NULL; - } - inode = ilookup5(sb, hash, coda_test_inode, fid); if ( !inode ) return NULL; -- 2.4.11
[PATCH 3/7 linux-next] coda: use SIZE() for stat
max_t expression was already defined in coda sources Signed-off-by: Fabian Frederick --- fs/coda/upcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index d0d0fed..1323793 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -553,7 +553,7 @@ int venus_statfs(struct dentry *dentry, struct kstatfs *sfs) union outputArgs *outp; int insize, outsize, error; - insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs)); + insize = SIZE(statfs); UPARG(CODA_STATFS); error = coda_upcall(coda_vcp(dentry->d_sb), insize, , inp); -- 2.4.11
[PATCH 5/7 linux-next] coda: remove sysctl object from module when unused
Inspired by NFS sysctl process Signed-off-by: Fabian Frederick --- fs/coda/Makefile | 3 ++- fs/coda/coda_int.h | 10 ++ fs/coda/coda_linux.h | 4 fs/coda/sysctl.c | 11 --- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/coda/Makefile b/fs/coda/Makefile index 1bab69a..30e4e1b 100644 --- a/fs/coda/Makefile +++ b/fs/coda/Makefile @@ -5,7 +5,8 @@ obj-$(CONFIG_CODA_FS) += coda.o coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \ -coda_linux.o symlink.o pioctl.o sysctl.o +coda_linux.o symlink.o pioctl.o +coda-$(CONFIG_SYSCTL) += sysctl.o # If you want debugging output, please uncomment the following line. diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h index bb0b3e0..f82b59c 100644 --- a/fs/coda/coda_int.h +++ b/fs/coda/coda_int.h @@ -13,9 +13,19 @@ extern int coda_fake_statfs; void coda_destroy_inodecache(void); int __init coda_init_inodecache(void); int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync); + +#ifdef CONFIG_SYSCTL void coda_sysctl_init(void); void coda_sysctl_clean(void); +#else +static inline void coda_sysctl_init(void) +{ +} +static inline void coda_sysctl_clean(void) +{ +} +#endif #endif /* _CODA_INT_ */ diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index 903f2a3..4087264 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h @@ -59,10 +59,6 @@ void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); unsigned short coda_flags_to_cflags(unsigned short); -/* sysctl.h */ -void coda_sysctl_init(void); -void coda_sysctl_clean(void); - #define CODA_ALLOC(ptr, cast, size) do { \ if (size < PAGE_SIZE) \ ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c index 0301d45..fda3b70 100644 --- a/fs/coda/sysctl.c +++ b/fs/coda/sysctl.c @@ -12,7 +12,6 @@ #include "coda_int.h" -#ifdef CONFIG_SYSCTL static struct ctl_table_header *fs_table_header; static struct ctl_table coda_table[] = { @@ -62,13 +61,3 @@ void coda_sysctl_clean(void) fs_table_header = NULL; } } - -#else -void coda_sysctl_init(void) -{ -} - -void coda_sysctl_clean(void) -{ -} -#endif -- 2.4.11
[PATCH 6/7 linux-next] coda: remove sb test in coda_fid_to_inode()
coda_fid_to_inode() is only called by coda_downcall() where sb is already being tested. Signed-off-by: Fabian Frederick --- fs/coda/cnode.c | 5 - 1 file changed, 5 deletions(-) diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index 845b5a6..c42d340 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c @@ -137,11 +137,6 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb) struct inode *inode; unsigned long hash = coda_f2i(fid); - if ( !sb ) { - pr_warn("%s: no sb!\n", __func__); - return NULL; - } - inode = ilookup5(sb, hash, coda_test_inode, fid); if ( !inode ) return NULL; -- 2.4.11
[PATCH 2/7 linux-next] coda: destroy mutex in put_super()
we can safely destroy vc_mutex at the end of umount process. Signed-off-by: Fabian Frederick --- fs/coda/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/coda/inode.c b/fs/coda/inode.c index dd819c1..69bb64d 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -244,6 +244,7 @@ static void coda_put_super(struct super_block *sb) vcp->vc_sb = NULL; sb->s_fs_info = NULL; mutex_unlock(>vc_mutex); + mutex_destroy(>vc_mutex); pr_info("Bye bye.\n"); } -- 2.4.11
[PATCH 7/7 linux-next] coda: ftoc validity check integration
This patch moves cfi check in coda_ftoc() instead of repeating it in the wild. Module size textdata bss dec hex filename 282971040 700 300377555 fs/coda/coda.ko.before 28263 980 700 2994374f7 fs/coda/coda.ko.after Signed-off-by: Fabian Frederick --- fs/coda/cnode.c | 10 ++ fs/coda/coda_fs_i.h | 3 +-- fs/coda/dir.c | 6 ++ fs/coda/file.c | 17 + 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index c42d340..36414438 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c @@ -148,6 +148,16 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb) return inode; } +struct coda_file_info *coda_ftoc(struct file *file) +{ + struct coda_file_info *cfi = file->private_data; + + BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + + return cfi; + +} + /* the CONTROL inode is made without asking attributes from Venus */ struct inode *coda_cnode_makectl(struct super_block *sb) { diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h index d702ba1a..c99d574 100644 --- a/fs/coda/coda_fs_i.h +++ b/fs/coda/coda_fs_i.h @@ -42,8 +42,6 @@ struct coda_file_info { unsigned int cfi_mapcount; /* nr of times this file is mapped */ }; -#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data)) - /* flags */ #define C_VATTR 0x1 /* Validity of vattr in inode */ #define C_FLUSH 0x2 /* used after a flush */ @@ -54,6 +52,7 @@ struct inode *coda_cnode_make(struct CodaFid *, struct super_block *); struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr); struct inode *coda_cnode_makectl(struct super_block *sb); struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb); +struct coda_file_info *coda_ftoc(struct file *file); void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *); #endif diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 00876dd..3e80770 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -356,8 +356,7 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx) ino_t ino; int ret; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; cii = ITOC(file_inode(coda_file)); @@ -426,8 +425,7 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx) struct file *host_file; int ret; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; if (host_file->f_op->iterate || host_file->f_op->iterate_shared) { diff --git a/fs/coda/file.c b/fs/coda/file.c index 1cbc1f2..55c22e2 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -31,9 +31,7 @@ static ssize_t coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *coda_file = iocb->ki_filp; - struct coda_file_info *cfi = CODA_FTOC(coda_file); - - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + struct coda_file_info *cfi = coda_ftoc(coda_file); return vfs_iter_read(cfi->cfi_container, to, >ki_pos, 0); } @@ -43,12 +41,10 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *coda_file = iocb->ki_filp; struct inode *coda_inode = file_inode(coda_file); - struct coda_file_info *cfi = CODA_FTOC(coda_file); + struct coda_file_info *cfi = coda_ftoc(coda_file); struct file *host_file; ssize_t ret; - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); - host_file = cfi->cfi_container; file_start_write(host_file); inode_lock(coda_inode); @@ -69,8 +65,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) struct file *host_file; struct inode *coda_inode, *host_inode; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; if (!host_file->f_op->mmap) @@ -142,8 +137,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) struct inode *host_inode; int err; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, coda_file->f_cred->fsuid); @@ -185,8 +179,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync) return err; inode_lock(coda_inode); - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_
[PATCH 2/7 linux-next] coda: destroy mutex in put_super()
we can safely destroy vc_mutex at the end of umount process. Signed-off-by: Fabian Frederick --- fs/coda/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/coda/inode.c b/fs/coda/inode.c index dd819c1..69bb64d 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -244,6 +244,7 @@ static void coda_put_super(struct super_block *sb) vcp->vc_sb = NULL; sb->s_fs_info = NULL; mutex_unlock(>vc_mutex); + mutex_destroy(>vc_mutex); pr_info("Bye bye.\n"); } -- 2.4.11
[PATCH 7/7 linux-next] coda: ftoc validity check integration
This patch moves cfi check in coda_ftoc() instead of repeating it in the wild. Module size textdata bss dec hex filename 282971040 700 300377555 fs/coda/coda.ko.before 28263 980 700 2994374f7 fs/coda/coda.ko.after Signed-off-by: Fabian Frederick --- fs/coda/cnode.c | 10 ++ fs/coda/coda_fs_i.h | 3 +-- fs/coda/dir.c | 6 ++ fs/coda/file.c | 17 + 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c index c42d340..36414438 100644 --- a/fs/coda/cnode.c +++ b/fs/coda/cnode.c @@ -148,6 +148,16 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb) return inode; } +struct coda_file_info *coda_ftoc(struct file *file) +{ + struct coda_file_info *cfi = file->private_data; + + BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + + return cfi; + +} + /* the CONTROL inode is made without asking attributes from Venus */ struct inode *coda_cnode_makectl(struct super_block *sb) { diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h index d702ba1a..c99d574 100644 --- a/fs/coda/coda_fs_i.h +++ b/fs/coda/coda_fs_i.h @@ -42,8 +42,6 @@ struct coda_file_info { unsigned int cfi_mapcount; /* nr of times this file is mapped */ }; -#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data)) - /* flags */ #define C_VATTR 0x1 /* Validity of vattr in inode */ #define C_FLUSH 0x2 /* used after a flush */ @@ -54,6 +52,7 @@ struct inode *coda_cnode_make(struct CodaFid *, struct super_block *); struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr); struct inode *coda_cnode_makectl(struct super_block *sb); struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb); +struct coda_file_info *coda_ftoc(struct file *file); void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *); #endif diff --git a/fs/coda/dir.c b/fs/coda/dir.c index 00876dd..3e80770 100644 --- a/fs/coda/dir.c +++ b/fs/coda/dir.c @@ -356,8 +356,7 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx) ino_t ino; int ret; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; cii = ITOC(file_inode(coda_file)); @@ -426,8 +425,7 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx) struct file *host_file; int ret; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; if (host_file->f_op->iterate || host_file->f_op->iterate_shared) { diff --git a/fs/coda/file.c b/fs/coda/file.c index 1cbc1f2..55c22e2 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -31,9 +31,7 @@ static ssize_t coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *coda_file = iocb->ki_filp; - struct coda_file_info *cfi = CODA_FTOC(coda_file); - - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + struct coda_file_info *cfi = coda_ftoc(coda_file); return vfs_iter_read(cfi->cfi_container, to, >ki_pos, 0); } @@ -43,12 +41,10 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *coda_file = iocb->ki_filp; struct inode *coda_inode = file_inode(coda_file); - struct coda_file_info *cfi = CODA_FTOC(coda_file); + struct coda_file_info *cfi = coda_ftoc(coda_file); struct file *host_file; ssize_t ret; - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); - host_file = cfi->cfi_container; file_start_write(host_file); inode_lock(coda_inode); @@ -69,8 +65,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) struct file *host_file; struct inode *coda_inode, *host_inode; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; if (!host_file->f_op->mmap) @@ -142,8 +137,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) struct inode *host_inode; int err; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, coda_file->f_cred->fsuid); @@ -185,8 +179,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync) return err; inode_lock(coda_inode); - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_
[PATCH 0/7 linux-next] coda: fs clean-up
This small patchset applies some sparse clean-up / optimizations Fabian Frederick (7): coda: remove CODA_FREE coda: destroy mutex in put_super() coda: use SIZE() for stat coda: add __init to init_coda_psdev() coda: remove sysctl object from module when unused coda: remove sb test in coda_fid_to_inode() coda: ftoc validity check integration fs/coda/Makefile | 3 ++- fs/coda/cnode.c | 15 ++- fs/coda/coda_fs_i.h | 3 +-- fs/coda/coda_int.h | 10 ++ fs/coda/coda_linux.h | 6 -- fs/coda/dir.c| 6 ++ fs/coda/file.c | 17 + fs/coda/inode.c | 1 + fs/coda/psdev.c | 10 +- fs/coda/sysctl.c | 11 --- fs/coda/upcall.c | 38 +++--- 11 files changed, 55 insertions(+), 65 deletions(-) -- 2.4.11
[PATCH 4/7 linux-next] coda: add __init to init_coda_psdev()
init_coda_psdev() was only called by __init function. Signed-off-by: Fabian Frederick --- fs/coda/psdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index cbdddf4..6d1c95f 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -352,7 +352,7 @@ static const struct file_operations coda_psdev_fops = { .llseek = noop_llseek, }; -static int init_coda_psdev(void) +static int __init init_coda_psdev(void) { int i, err = 0; if (register_chrdev(CODA_PSDEV_MAJOR, "coda", _psdev_fops)) { -- 2.4.11
[PATCH 0/7 linux-next] coda: fs clean-up
This small patchset applies some sparse clean-up / optimizations Fabian Frederick (7): coda: remove CODA_FREE coda: destroy mutex in put_super() coda: use SIZE() for stat coda: add __init to init_coda_psdev() coda: remove sysctl object from module when unused coda: remove sb test in coda_fid_to_inode() coda: ftoc validity check integration fs/coda/Makefile | 3 ++- fs/coda/cnode.c | 15 ++- fs/coda/coda_fs_i.h | 3 +-- fs/coda/coda_int.h | 10 ++ fs/coda/coda_linux.h | 6 -- fs/coda/dir.c| 6 ++ fs/coda/file.c | 17 + fs/coda/inode.c | 1 + fs/coda/psdev.c | 10 +- fs/coda/sysctl.c | 11 --- fs/coda/upcall.c | 38 +++--- 11 files changed, 55 insertions(+), 65 deletions(-) -- 2.4.11
[PATCH 4/7 linux-next] coda: add __init to init_coda_psdev()
init_coda_psdev() was only called by __init function. Signed-off-by: Fabian Frederick --- fs/coda/psdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index cbdddf4..6d1c95f 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -352,7 +352,7 @@ static const struct file_operations coda_psdev_fops = { .llseek = noop_llseek, }; -static int init_coda_psdev(void) +static int __init init_coda_psdev(void) { int i, err = 0; if (register_chrdev(CODA_PSDEV_MAJOR, "coda", _psdev_fops)) { -- 2.4.11
[PATCH 1/7 linux-next] coda: remove CODA_FREE
Since commit 1d5cfdb07628 ("tree wide: use kvfree() than conditional kfree()/vfree()") size in CODA_FREE is no longer used and that macro hides nothing more than kvfree() Signed-off-by: Fabian Frederick --- fs/coda/coda_linux.h | 2 -- fs/coda/psdev.c | 8 fs/coda/upcall.c | 36 ++-- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index 126155c..903f2a3 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h @@ -73,8 +73,6 @@ void coda_sysctl_clean(void); } while (0) -#define CODA_FREE(ptr, size) kvfree((ptr)) - /* inode to cnode access functions */ static inline struct coda_inode_info *ITOC(struct inode *inode) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index c5234c2..cbdddf4 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -126,7 +126,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, } CODA_ALLOC(dcbuf, union outputArgs *, nbytes); if (copy_from_user(dcbuf, buf, nbytes)) { - CODA_FREE(dcbuf, nbytes); + kvfree(dcbuf); retval = -EFAULT; goto out; } @@ -134,7 +134,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, /* what downcall errors does Venus handle ? */ error = coda_downcall(vcp, hdr.opcode, dcbuf); - CODA_FREE(dcbuf, nbytes); + kvfree(dcbuf); if (error) { pr_warn("%s: coda_downcall error: %d\n", __func__, error); @@ -257,7 +257,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, goto out; } - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); + kvfree(req->uc_data); kfree(req); out: mutex_unlock(>vc_mutex); @@ -319,7 +319,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file) /* Async requests need to be freed here */ if (req->uc_flags & CODA_REQ_ASYNC) { - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); + kvfree(req->uc_data); kfree(req); continue; } diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 1175a17..d0d0fed 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -85,7 +85,7 @@ int venus_rootfid(struct super_block *sb, struct CodaFid *fidp) if (!error) *fidp = outp->coda_root.VFid; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -104,7 +104,7 @@ int venus_getattr(struct super_block *sb, struct CodaFid *fid, if (!error) *attr = outp->coda_getattr.attr; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -123,7 +123,7 @@ int venus_setattr(struct super_block *sb, struct CodaFid *fid, error = coda_upcall(coda_vcp(sb), insize, , inp); -CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -153,7 +153,7 @@ int venus_lookup(struct super_block *sb, struct CodaFid *fid, *type = outp->coda_lookup.vtype; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -173,7 +173,7 @@ int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -194,7 +194,7 @@ int venus_open(struct super_block *sb, struct CodaFid *fid, if (!error) *fh = outp->coda_open_by_fd.fh; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -224,7 +224,7 @@ int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, *newfid = outp->coda_mkdir.VFid; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -262,7 +262,7 @@ int venus_rename(struct super_block *sb, struct CodaFid *old_fid, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -295,7 +295,7 @@ int venus_create(struct super_block *sb, struct CodaFid *dirfid, *newfid = outp->coda_create.VFid; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -318,7 +318,7 @@ int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -340,7 +340,7 @@ int venus_remove(struct super_block *sb, struct
[PATCH 1/7 linux-next] coda: remove CODA_FREE
Since commit 1d5cfdb07628 ("tree wide: use kvfree() than conditional kfree()/vfree()") size in CODA_FREE is no longer used and that macro hides nothing more than kvfree() Signed-off-by: Fabian Frederick --- fs/coda/coda_linux.h | 2 -- fs/coda/psdev.c | 8 fs/coda/upcall.c | 36 ++-- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h index 126155c..903f2a3 100644 --- a/fs/coda/coda_linux.h +++ b/fs/coda/coda_linux.h @@ -73,8 +73,6 @@ void coda_sysctl_clean(void); } while (0) -#define CODA_FREE(ptr, size) kvfree((ptr)) - /* inode to cnode access functions */ static inline struct coda_inode_info *ITOC(struct inode *inode) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index c5234c2..cbdddf4 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -126,7 +126,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, } CODA_ALLOC(dcbuf, union outputArgs *, nbytes); if (copy_from_user(dcbuf, buf, nbytes)) { - CODA_FREE(dcbuf, nbytes); + kvfree(dcbuf); retval = -EFAULT; goto out; } @@ -134,7 +134,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, /* what downcall errors does Venus handle ? */ error = coda_downcall(vcp, hdr.opcode, dcbuf); - CODA_FREE(dcbuf, nbytes); + kvfree(dcbuf); if (error) { pr_warn("%s: coda_downcall error: %d\n", __func__, error); @@ -257,7 +257,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf, goto out; } - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); + kvfree(req->uc_data); kfree(req); out: mutex_unlock(>vc_mutex); @@ -319,7 +319,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file) /* Async requests need to be freed here */ if (req->uc_flags & CODA_REQ_ASYNC) { - CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr)); + kvfree(req->uc_data); kfree(req); continue; } diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 1175a17..d0d0fed 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c @@ -85,7 +85,7 @@ int venus_rootfid(struct super_block *sb, struct CodaFid *fidp) if (!error) *fidp = outp->coda_root.VFid; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -104,7 +104,7 @@ int venus_getattr(struct super_block *sb, struct CodaFid *fid, if (!error) *attr = outp->coda_getattr.attr; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -123,7 +123,7 @@ int venus_setattr(struct super_block *sb, struct CodaFid *fid, error = coda_upcall(coda_vcp(sb), insize, , inp); -CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -153,7 +153,7 @@ int venus_lookup(struct super_block *sb, struct CodaFid *fid, *type = outp->coda_lookup.vtype; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -173,7 +173,7 @@ int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -194,7 +194,7 @@ int venus_open(struct super_block *sb, struct CodaFid *fid, if (!error) *fh = outp->coda_open_by_fd.fh; - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -224,7 +224,7 @@ int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, *newfid = outp->coda_mkdir.VFid; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -262,7 +262,7 @@ int venus_rename(struct super_block *sb, struct CodaFid *old_fid, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -295,7 +295,7 @@ int venus_create(struct super_block *sb, struct CodaFid *dirfid, *newfid = outp->coda_create.VFid; } - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -318,7 +318,7 @@ int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, error = coda_upcall(coda_vcp(sb), insize, , inp); - CODA_FREE(inp, insize); + kvfree(inp); return error; } @@ -340,7 +340,7 @@ int venus_remove(struct super_block *sb, struct
[tip:efi/core] efi/capsule: Remove NULL test on kmap()
Commit-ID: 171fd0222957abe28e6d78de667f457376f45cf1 Gitweb: http://git.kernel.org/tip/171fd0222957abe28e6d78de667f457376f45cf1 Author: Fabian Frederick <f...@skynet.be> AuthorDate: Fri, 2 Jun 2017 13:52:01 + Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Mon, 5 Jun 2017 17:50:40 +0200 efi/capsule: Remove NULL test on kmap() kmap() can't fail. Signed-off-by: Fabian Frederick <f...@skynet.be> Signed-off-by: Matt Fleming <m...@codeblueprint.co.uk> Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> Cc: Kweh Hock Leong <hock.leong.k...@intel.com> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: linux-...@vger.kernel.org Link: http://lkml.kernel.org/r/20170602135207.21708-8-ard.biesheu...@linaro.org Signed-off-by: Ingo Molnar <mi...@kernel.org> --- drivers/firmware/efi/capsule-loader.c | 4 drivers/firmware/efi/capsule.c| 4 2 files changed, 8 deletions(-) diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 5b012a4..2357bcd 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -170,10 +170,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, page = cap_info->pages[cap_info->index - 1]; kbuff = kmap(page); - if (!kbuff) { - ret = -ENOMEM; - goto failed; - } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; /* Copy capsule binary data from user space to kernel space buffer */ diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 6eedff4..e603ccf 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -247,10 +247,6 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages) efi_capsule_block_desc_t *sglist; sglist = kmap(sg_pages[i]); - if (!sglist) { - rv = -ENOMEM; - goto out; - } for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, PAGE_SIZE);
[tip:efi/core] efi/capsule: Remove NULL test on kmap()
Commit-ID: 171fd0222957abe28e6d78de667f457376f45cf1 Gitweb: http://git.kernel.org/tip/171fd0222957abe28e6d78de667f457376f45cf1 Author: Fabian Frederick AuthorDate: Fri, 2 Jun 2017 13:52:01 + Committer: Ingo Molnar CommitDate: Mon, 5 Jun 2017 17:50:40 +0200 efi/capsule: Remove NULL test on kmap() kmap() can't fail. Signed-off-by: Fabian Frederick Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel Cc: Kweh Hock Leong Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-...@vger.kernel.org Link: http://lkml.kernel.org/r/20170602135207.21708-8-ard.biesheu...@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/capsule-loader.c | 4 drivers/firmware/efi/capsule.c| 4 2 files changed, 8 deletions(-) diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 5b012a4..2357bcd 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -170,10 +170,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, page = cap_info->pages[cap_info->index - 1]; kbuff = kmap(page); - if (!kbuff) { - ret = -ENOMEM; - goto failed; - } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; /* Copy capsule binary data from user space to kernel space buffer */ diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 6eedff4..e603ccf 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -247,10 +247,6 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages) efi_capsule_block_desc_t *sglist; sglist = kmap(sg_pages[i]); - if (!sglist) { - rv = -ENOMEM; - goto out; - } for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, PAGE_SIZE);
Re: [PATCH 00/11 linux-next] super magic values consolidation
> On 28 May 2017 at 11:34 Christoph Hellwig <h...@infradead.org> wrote: > > > On Sun, May 21, 2017 at 05:39:47PM +0200, Fabian Frederick wrote: > > This small patchset reorganizes magic.h and fixes filesystems > > which defined locally super magic values. > > And what's the point? Current magic.h organization is strange for the less. Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition plus it looks easier for new subsystems to look at just one file when seeking for unique value.
Re: [PATCH 00/11 linux-next] super magic values consolidation
> On 28 May 2017 at 11:34 Christoph Hellwig wrote: > > > On Sun, May 21, 2017 at 05:39:47PM +0200, Fabian Frederick wrote: > > This small patchset reorganizes magic.h and fixes filesystems > > which defined locally super magic values. > > And what's the point? Current magic.h organization is strange for the less. Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition plus it looks easier for new subsystems to look at just one file when seeking for unique value.
[PATCH 11/11 linux-next] hfsplus: export super magic value
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/hfsplus/hfsplus_raw.h | 1 - include/uapi/linux/magic.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 80554d4..246d22d 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h @@ -22,7 +22,6 @@ #define HFSPLUS_VOLHEAD_SECTOR 2 #define HFSPLUS_VOLHEAD_SIG 0x482b #define HFSPLUS_VOLHEAD_SIGX0x4858 -#define HFSPLUS_SUPER_MAGIC 0x482b #define HFSPLUS_MIN_VERSION 4 #define HFSPLUS_CURRENT_VERSION 5 diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 8690964..c0df8e1 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -34,6 +34,7 @@ #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ #define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ +#define HFSPLUS_SUPER_MAGIC 0x482b #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -- 2.9.3
[PATCH 11/11 linux-next] hfsplus: export super magic value
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/hfsplus/hfsplus_raw.h | 1 - include/uapi/linux/magic.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 80554d4..246d22d 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h @@ -22,7 +22,6 @@ #define HFSPLUS_VOLHEAD_SECTOR 2 #define HFSPLUS_VOLHEAD_SIG 0x482b #define HFSPLUS_VOLHEAD_SIGX0x4858 -#define HFSPLUS_SUPER_MAGIC 0x482b #define HFSPLUS_MIN_VERSION 4 #define HFSPLUS_CURRENT_VERSION 5 diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 8690964..c0df8e1 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -34,6 +34,7 @@ #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ #define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ +#define HFSPLUS_SUPER_MAGIC 0x482b #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -- 2.9.3
[PATCH 10/11 linux-next] fs: define hfs super magic values globally
hfs values were defined twice (in hfs and hfsplus) This patch exports values globally and include magic.h in hfs.h and hfsplus_raw.h where other magic are going to be exported as well. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/hfs/hfs.h | 4 ++-- fs/hfsplus/hfsplus_raw.h | 1 + fs/hfsplus/part_tbl.c | 2 -- include/uapi/linux/magic.h | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/hfs/hfs.h b/fs/hfs/hfs.h index 6f194d0..4a10a84 100644 --- a/fs/hfs/hfs.h +++ b/fs/hfs/hfs.h @@ -9,6 +9,8 @@ #ifndef _HFS_H #define _HFS_H +#include + /* offsets to various blocks */ #define HFS_DD_BLK 0 /* Driver Descriptor block */ #define HFS_PMAP_BLK 1 /* First block of partition map */ @@ -18,8 +20,6 @@ #define HFS_DRVR_DESC_MAGIC0x4552 /* "ER": driver descriptor map */ #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ -#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ -#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ /* various FIXED size parameters */ #define HFS_SECTOR_SIZE512/* size of an HFS sector */ diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 8298d09..80554d4 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h @@ -14,6 +14,7 @@ #define _LINUX_HFSPLUS_RAW_H #include +#include /* Some constants */ #define HFSPLUS_SECTOR_SIZE512 diff --git a/fs/hfsplus/part_tbl.c b/fs/hfsplus/part_tbl.c index 63164eb..12d3e0b 100644 --- a/fs/hfsplus/part_tbl.c +++ b/fs/hfsplus/part_tbl.c @@ -26,8 +26,6 @@ #define HFS_DRVR_DESC_MAGIC0x4552 /* "ER": driver descriptor map */ #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ -#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ -#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ /* * The new style Mac partition map diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e61d5af..8690964 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -32,6 +32,8 @@ #define FUSE_CTL_SUPER_MAGIC 0x65735543 #define FUSE_SUPER_MAGIC 0x65735546 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA +#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ +#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -- 2.9.3
[PATCH 09/11 linux-next] freevxfs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/freevxfs/vxfs.h | 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/freevxfs/vxfs.h b/fs/freevxfs/vxfs.h index a41ea0b..3bde7dd 100644 --- a/fs/freevxfs/vxfs.h +++ b/fs/freevxfs/vxfs.h @@ -38,11 +38,7 @@ * superblocks of the Veritas Filesystem. */ #include - -/* - * Superblock magic number (vxfs_super->vs_magic). - */ -#define VXFS_SUPER_MAGIC 0xa501FCF5 +#include /* * The root inode. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 6afc4b2..e61d5af 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -78,6 +78,7 @@ #define UDF_SUPER_MAGIC0x15013346 /* Since UDF 2.01 is ISO 13346 based... */ #define USBDEVICE_SUPER_MAGIC 0x9fa2 #define V9FS_MAGIC 0x01021997 +#define VXFS_SUPER_MAGIC 0xa501FCF5 #define XENFS_SUPER_MAGIC 0xabba1974 #define ZSMALLOC_MAGIC 0x58295829 -- 2.9.3
[PATCH 08/11 linux-next] fuse: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/fuse/control.c | 3 +-- fs/fuse/inode.c| 3 +-- include/uapi/linux/magic.h | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/control.c b/fs/fuse/control.c index b9ea99c..9015c15 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -10,8 +10,7 @@ #include #include - -#define FUSE_CTL_SUPER_MAGIC 0x65735543 +#include /* * This is non-NULL when the single instance of the control filesystem diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5a1b58f..5362761 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -22,6 +22,7 @@ #include #include #include +#include MODULE_AUTHOR("Miklos Szeredi <mik...@szeredi.hu>"); MODULE_DESCRIPTION("Filesystem in Userspace"); @@ -49,8 +50,6 @@ MODULE_PARM_DESC(max_user_congthresh, "Global limit for the maximum congestion threshold an " "unprivileged user can set"); -#define FUSE_SUPER_MAGIC 0x65735546 - #define FUSE_DEFAULT_BLKSIZE 512 /** Maximum number of outstanding background requests */ diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 2621eaf..6afc4b2 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -29,6 +29,8 @@ #define EXT4_SUPER_MAGIC 0xEF53 #define EXOFS_SUPER_MAGIC 0x5DF5 #define F2FS_SUPER_MAGIC 0xF2F52010 +#define FUSE_CTL_SUPER_MAGIC 0x65735543 +#define FUSE_SUPER_MAGIC 0x65735546 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 -- 2.9.3
[PATCH 10/11 linux-next] fs: define hfs super magic values globally
hfs values were defined twice (in hfs and hfsplus) This patch exports values globally and include magic.h in hfs.h and hfsplus_raw.h where other magic are going to be exported as well. Signed-off-by: Fabian Frederick --- fs/hfs/hfs.h | 4 ++-- fs/hfsplus/hfsplus_raw.h | 1 + fs/hfsplus/part_tbl.c | 2 -- include/uapi/linux/magic.h | 2 ++ 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/hfs/hfs.h b/fs/hfs/hfs.h index 6f194d0..4a10a84 100644 --- a/fs/hfs/hfs.h +++ b/fs/hfs/hfs.h @@ -9,6 +9,8 @@ #ifndef _HFS_H #define _HFS_H +#include + /* offsets to various blocks */ #define HFS_DD_BLK 0 /* Driver Descriptor block */ #define HFS_PMAP_BLK 1 /* First block of partition map */ @@ -18,8 +20,6 @@ #define HFS_DRVR_DESC_MAGIC0x4552 /* "ER": driver descriptor map */ #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ -#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ -#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ /* various FIXED size parameters */ #define HFS_SECTOR_SIZE512/* size of an HFS sector */ diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h index 8298d09..80554d4 100644 --- a/fs/hfsplus/hfsplus_raw.h +++ b/fs/hfsplus/hfsplus_raw.h @@ -14,6 +14,7 @@ #define _LINUX_HFSPLUS_RAW_H #include +#include /* Some constants */ #define HFSPLUS_SECTOR_SIZE512 diff --git a/fs/hfsplus/part_tbl.c b/fs/hfsplus/part_tbl.c index 63164eb..12d3e0b 100644 --- a/fs/hfsplus/part_tbl.c +++ b/fs/hfsplus/part_tbl.c @@ -26,8 +26,6 @@ #define HFS_DRVR_DESC_MAGIC0x4552 /* "ER": driver descriptor map */ #define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */ #define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */ -#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ -#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ /* * The new style Mac partition map diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e61d5af..8690964 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -32,6 +32,8 @@ #define FUSE_CTL_SUPER_MAGIC 0x65735543 #define FUSE_SUPER_MAGIC 0x65735546 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA +#define HFS_SUPER_MAGIC0x4244 /* "BD": HFS MDB (super block) */ +#define HFS_MFS_SUPER_MAGIC0xD2D7 /* MFS MDB (super block) */ #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -- 2.9.3
[PATCH 09/11 linux-next] freevxfs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/freevxfs/vxfs.h | 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/freevxfs/vxfs.h b/fs/freevxfs/vxfs.h index a41ea0b..3bde7dd 100644 --- a/fs/freevxfs/vxfs.h +++ b/fs/freevxfs/vxfs.h @@ -38,11 +38,7 @@ * superblocks of the Veritas Filesystem. */ #include - -/* - * Superblock magic number (vxfs_super->vs_magic). - */ -#define VXFS_SUPER_MAGIC 0xa501FCF5 +#include /* * The root inode. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 6afc4b2..e61d5af 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -78,6 +78,7 @@ #define UDF_SUPER_MAGIC0x15013346 /* Since UDF 2.01 is ISO 13346 based... */ #define USBDEVICE_SUPER_MAGIC 0x9fa2 #define V9FS_MAGIC 0x01021997 +#define VXFS_SUPER_MAGIC 0xa501FCF5 #define XENFS_SUPER_MAGIC 0xabba1974 #define ZSMALLOC_MAGIC 0x58295829 -- 2.9.3
[PATCH 08/11 linux-next] fuse: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/fuse/control.c | 3 +-- fs/fuse/inode.c| 3 +-- include/uapi/linux/magic.h | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fuse/control.c b/fs/fuse/control.c index b9ea99c..9015c15 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -10,8 +10,7 @@ #include #include - -#define FUSE_CTL_SUPER_MAGIC 0x65735543 +#include /* * This is non-NULL when the single instance of the control filesystem diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5a1b58f..5362761 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -22,6 +22,7 @@ #include #include #include +#include MODULE_AUTHOR("Miklos Szeredi "); MODULE_DESCRIPTION("Filesystem in Userspace"); @@ -49,8 +50,6 @@ MODULE_PARM_DESC(max_user_congthresh, "Global limit for the maximum congestion threshold an " "unprivileged user can set"); -#define FUSE_SUPER_MAGIC 0x65735546 - #define FUSE_DEFAULT_BLKSIZE 512 /** Maximum number of outstanding background requests */ diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 2621eaf..6afc4b2 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -29,6 +29,8 @@ #define EXT4_SUPER_MAGIC 0xEF53 #define EXOFS_SUPER_MAGIC 0x5DF5 #define F2FS_SUPER_MAGIC 0xF2F52010 +#define FUSE_CTL_SUPER_MAGIC 0x65735543 +#define FUSE_SUPER_MAGIC 0x65735546 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 -- 2.9.3
[PATCH 05/11 linux-next] ubifs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/ubifs/ubifs.h | 4 +--- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 298b4d8..abc60d5 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef CONFIG_UBIFS_FS_ENCRYPTION #include #else @@ -49,9 +50,6 @@ /* Version of this UBIFS implementation */ #define UBIFS_VERSION 1 -/* UBIFS file system VFS magic number */ -#define UBIFS_SUPER_MAGIC 0x24051905 - /* Number of UBIFS blocks per VFS page */ #define UBIFS_BLOCKS_PER_PAGE (PAGE_SIZE / UBIFS_BLOCK_SIZE) #define UBIFS_BLOCKS_PER_PAGE_SHIFT (PAGE_SHIFT - UBIFS_BLOCK_SHIFT) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index a83c48f..b651a02 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -70,6 +70,7 @@ #define SYSFS_MAGIC0x62656572 #define TMPFS_MAGIC0x01021994 #define TRACEFS_MAGIC 0x74726163 +#define UBIFS_SUPER_MAGIC 0x24051905 #define UDF_SUPER_MAGIC0x15013346 /* Since UDF 2.01 is ISO 13346 based... */ #define USBDEVICE_SUPER_MAGIC 0x9fa2 #define V9FS_MAGIC 0x01021997 -- 2.9.3
[PATCH 07/11 linux-next] ocfs2: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/ocfs2/ocfs2_fs.h| 5 ++--- include/uapi/linux/magic.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 44d178b..5bb4a89 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h @@ -25,6 +25,8 @@ #ifndef _OCFS2_FS_H #define _OCFS2_FS_H +#include + /* Version */ #define OCFS2_MAJOR_REV_LEVEL 0 #define OCFS2_MINOR_REV_LEVEL 90 @@ -56,9 +58,6 @@ #define OCFS2_MIN_BLOCKSIZE512 #define OCFS2_MAX_BLOCKSIZEOCFS2_MIN_CLUSTERSIZE -/* Filesystem magic number */ -#define OCFS2_SUPER_MAGIC 0x7461636f - /* Object signatures */ #define OCFS2_SUPER_BLOCK_SIGNATURE"OCFSV2" #define OCFS2_INODE_SIGNATURE "INODE01" diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 905eaa2..2621eaf 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -47,6 +47,7 @@ #define NFS_SUPER_MAGIC0x6969 #define NILFS_SUPER_MAGIC 0x3434 #define NSFS_MAGIC 0x6e736673 +#define OCFS2_SUPER_MAGIC 0x7461636f #define OPENPROM_SUPER_MAGIC 0x9fa1 #define ORANGEFS_SUPER_MAGIC 0x20030528 #define OVERLAYFS_SUPER_MAGIC 0x794c7630 -- 2.9.3
[PATCH 05/11 linux-next] ubifs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/ubifs/ubifs.h | 4 +--- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 298b4d8..abc60d5 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef CONFIG_UBIFS_FS_ENCRYPTION #include #else @@ -49,9 +50,6 @@ /* Version of this UBIFS implementation */ #define UBIFS_VERSION 1 -/* UBIFS file system VFS magic number */ -#define UBIFS_SUPER_MAGIC 0x24051905 - /* Number of UBIFS blocks per VFS page */ #define UBIFS_BLOCKS_PER_PAGE (PAGE_SIZE / UBIFS_BLOCK_SIZE) #define UBIFS_BLOCKS_PER_PAGE_SHIFT (PAGE_SHIFT - UBIFS_BLOCK_SHIFT) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index a83c48f..b651a02 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -70,6 +70,7 @@ #define SYSFS_MAGIC0x62656572 #define TMPFS_MAGIC0x01021994 #define TRACEFS_MAGIC 0x74726163 +#define UBIFS_SUPER_MAGIC 0x24051905 #define UDF_SUPER_MAGIC0x15013346 /* Since UDF 2.01 is ISO 13346 based... */ #define USBDEVICE_SUPER_MAGIC 0x9fa2 #define V9FS_MAGIC 0x01021997 -- 2.9.3
[PATCH 07/11 linux-next] ocfs2: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/ocfs2/ocfs2_fs.h| 5 ++--- include/uapi/linux/magic.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 44d178b..5bb4a89 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h @@ -25,6 +25,8 @@ #ifndef _OCFS2_FS_H #define _OCFS2_FS_H +#include + /* Version */ #define OCFS2_MAJOR_REV_LEVEL 0 #define OCFS2_MINOR_REV_LEVEL 90 @@ -56,9 +58,6 @@ #define OCFS2_MIN_BLOCKSIZE512 #define OCFS2_MAX_BLOCKSIZEOCFS2_MIN_CLUSTERSIZE -/* Filesystem magic number */ -#define OCFS2_SUPER_MAGIC 0x7461636f - /* Object signatures */ #define OCFS2_SUPER_BLOCK_SIGNATURE"OCFSV2" #define OCFS2_INODE_SIGNATURE "INODE01" diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 905eaa2..2621eaf 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -47,6 +47,7 @@ #define NFS_SUPER_MAGIC0x6969 #define NILFS_SUPER_MAGIC 0x3434 #define NSFS_MAGIC 0x6e736673 +#define OCFS2_SUPER_MAGIC 0x7461636f #define OPENPROM_SUPER_MAGIC 0x9fa1 #define ORANGEFS_SUPER_MAGIC 0x20030528 #define OVERLAYFS_SUPER_MAGIC 0x794c7630 -- 2.9.3
[PATCH 06/11 linux-next] jfs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/jfs/jfs_incore.h| 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h index 1f26d19..64b9152 100644 --- a/fs/jfs/jfs_incore.h +++ b/fs/jfs/jfs_incore.h @@ -23,16 +23,12 @@ #include #include #include +#include #include "jfs_types.h" #include "jfs_xtree.h" #include "jfs_dtree.h" /* - * JFS magic number - */ -#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */ - -/* * JFS-private inode information */ struct jfs_inode_info { diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index b651a02..905eaa2 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -34,6 +34,7 @@ #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ #define ISOFS_SUPER_MAGIC 0x9660 +#define JFS_SUPER_MAGIC0x3153464a /* "JFS1" */ #define JFFS2_SUPER_MAGIC 0x72b6 #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ #define MINIX2_SUPER_MAGIC20x2478 /* minix v2 fs, 30 char names */ -- 2.9.3
[PATCH 06/11 linux-next] jfs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/jfs/jfs_incore.h| 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/jfs/jfs_incore.h b/fs/jfs/jfs_incore.h index 1f26d19..64b9152 100644 --- a/fs/jfs/jfs_incore.h +++ b/fs/jfs/jfs_incore.h @@ -23,16 +23,12 @@ #include #include #include +#include #include "jfs_types.h" #include "jfs_xtree.h" #include "jfs_dtree.h" /* - * JFS magic number - */ -#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */ - -/* * JFS-private inode information */ struct jfs_inode_info { diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index b651a02..905eaa2 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -34,6 +34,7 @@ #define HPFS_SUPER_MAGIC 0xf995e849 #define HUGETLBFS_MAGIC0x958458f6 /* some random number */ #define ISOFS_SUPER_MAGIC 0x9660 +#define JFS_SUPER_MAGIC0x3153464a /* "JFS1" */ #define JFFS2_SUPER_MAGIC 0x72b6 #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ #define MINIX2_SUPER_MAGIC20x2478 /* minix v2 fs, 30 char names */ -- 2.9.3
[PATCH 04/11 linux-next] orangefs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/orangefs/protocol.h | 3 +-- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index 48bcc1b..a511ac6 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h @@ -3,6 +3,7 @@ #include #include #include +#include /* pvfs2-config.h ***/ #define ORANGEFS_VERSION_MAJOR 2 @@ -80,8 +81,6 @@ typedef __u64 ORANGEFS_ds_position; typedef __s32 ORANGEFS_error; typedef __s64 ORANGEFS_offset; -#define ORANGEFS_SUPER_MAGIC 0x20030528 - /* * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but * the sign is stripped before decoding. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 507f3c3..a83c48f 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -47,6 +47,7 @@ #define NILFS_SUPER_MAGIC 0x3434 #define NSFS_MAGIC 0x6e736673 #define OPENPROM_SUPER_MAGIC 0x9fa1 +#define ORANGEFS_SUPER_MAGIC 0x20030528 #define OVERLAYFS_SUPER_MAGIC 0x794c7630 #define PIPEFS_MAGIC 0x50495045 #define PROC_SUPER_MAGIC 0x9fa0 -- 2.9.3
[PATCH 04/11 linux-next] orangefs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/orangefs/protocol.h | 3 +-- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index 48bcc1b..a511ac6 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h @@ -3,6 +3,7 @@ #include #include #include +#include /* pvfs2-config.h ***/ #define ORANGEFS_VERSION_MAJOR 2 @@ -80,8 +81,6 @@ typedef __u64 ORANGEFS_ds_position; typedef __s32 ORANGEFS_error; typedef __s64 ORANGEFS_offset; -#define ORANGEFS_SUPER_MAGIC 0x20030528 - /* * ORANGEFS error codes are a signed 32-bit integer. Error codes are negative, but * the sign is stripped before decoding. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 507f3c3..a83c48f 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -47,6 +47,7 @@ #define NILFS_SUPER_MAGIC 0x3434 #define NSFS_MAGIC 0x6e736673 #define OPENPROM_SUPER_MAGIC 0x9fa1 +#define ORANGEFS_SUPER_MAGIC 0x20030528 #define OVERLAYFS_SUPER_MAGIC 0x794c7630 #define PIPEFS_MAGIC 0x50495045 #define PROC_SUPER_MAGIC 0x9fa0 -- 2.9.3
[PATCH 03/11 linux-next] ceph: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/ceph/super.h| 4 +--- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ceph/super.h b/fs/ceph/super.h index a973acd..8be85c4 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -22,9 +23,6 @@ #include #endif -/* f_type in struct statfs */ -#define CEPH_SUPER_MAGIC 0x00c36400 - /* large granularity for statfs utilization stats to facilitate * large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22 /* 4 MB */ diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 1265355..507f3c3 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -12,6 +12,7 @@ #define BPF_FS_MAGIC 0xcafe4a11 #define BTRFS_SUPER_MAGIC 0x9123683E #define BTRFS_TEST_MAGIC 0x73727279 +#define CEPH_SUPER_MAGIC 0x00c36400 #define CGROUP2_SUPER_MAGIC0x63677270 #define CGROUP_SUPER_MAGIC 0x27e0eb #define CODA_SUPER_MAGIC 0x73757245 -- 2.9.3
[PATCH 03/11 linux-next] ceph: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/ceph/super.h| 4 +--- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ceph/super.h b/fs/ceph/super.h index a973acd..8be85c4 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -22,9 +23,6 @@ #include #endif -/* f_type in struct statfs */ -#define CEPH_SUPER_MAGIC 0x00c36400 - /* large granularity for statfs utilization stats to facilitate * large volume sizes on 32-bit machines. */ #define CEPH_BLOCK_SHIFT 22 /* 4 MB */ diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 1265355..507f3c3 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -12,6 +12,7 @@ #define BPF_FS_MAGIC 0xcafe4a11 #define BTRFS_SUPER_MAGIC 0x9123683E #define BTRFS_TEST_MAGIC 0x73727279 +#define CEPH_SUPER_MAGIC 0x00c36400 #define CGROUP2_SUPER_MAGIC0x63677270 #define CGROUP_SUPER_MAGIC 0x27e0eb #define CODA_SUPER_MAGIC 0x73757245 -- 2.9.3
[PATCH 01/11 linux-next] uapi: reorganize magic.h
-Sort magic.h in alphabetical order as there were no real logic in this file. -Replace all spaces with tabs -Remove excessive comments for reiserfs Signed-off-by: Fabian Frederick <f...@skynet.be> --- include/uapi/linux/magic.h | 92 -- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e230af2..e3bb43b 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -3,86 +3,74 @@ #define ADFS_SUPER_MAGIC 0xadf5 #define AFFS_SUPER_MAGIC 0xadff -#define AFS_SUPER_MAGIC0x5346414F +#define AFS_SUPER_MAGIC0x5346414F +#define ANON_INODE_FS_MAGIC0x09041934 #define AUTOFS_SUPER_MAGIC 0x0187 +#define BALLOON_KVM_MAGIC 0x13661366 +#define BDEVFS_MAGIC 0x62646576 +#define BINFMTFS_MAGIC 0x42494e4d +#define BPF_FS_MAGIC 0xcafe4a11 +#define BTRFS_SUPER_MAGIC 0x9123683E +#define BTRFS_TEST_MAGIC 0x73727279 +#define CGROUP2_SUPER_MAGIC0x63677270 +#define CGROUP_SUPER_MAGIC 0x27e0eb #define CODA_SUPER_MAGIC 0x73757245 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ -#define DEBUGFS_MAGIC 0x64626720 -#define SECURITYFS_MAGIC 0x73636673 -#define SELINUX_MAGIC 0xf97cff8c -#define SMACK_MAGIC0x43415d53 /* "SMAC" */ -#define RAMFS_MAGIC0x858458f6 /* some random number */ -#define TMPFS_MAGIC0x01021994 -#define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -#define SQUASHFS_MAGIC 0x73717368 +#define DAXFS_MAGIC0x64646178 +#define DEBUGFS_MAGIC 0x64626720 +#define DEVPTS_SUPER_MAGIC 0x1cd1 #define ECRYPTFS_SUPER_MAGIC 0xf15f +#define EFIVARFS_MAGIC 0xde5e81e4 #define EFS_SUPER_MAGIC0x414A53 #define EXT2_SUPER_MAGIC 0xEF53 #define EXT3_SUPER_MAGIC 0xEF53 -#define XENFS_SUPER_MAGIC 0xabba1974 #define EXT4_SUPER_MAGIC 0xEF53 -#define BTRFS_SUPER_MAGIC 0x9123683E -#define NILFS_SUPER_MAGIC 0x3434 #define F2FS_SUPER_MAGIC 0xF2F52010 +#define FUTEXFS_SUPER_MAGIC0xBAD1DEA +#define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 +#define HUGETLBFS_MAGIC0x958458f6 /* some random number */ #define ISOFS_SUPER_MAGIC 0x9660 #define JFFS2_SUPER_MAGIC 0x72b6 -#define PSTOREFS_MAGIC 0x6165676C -#define EFIVARFS_MAGIC 0xde5e81e4 -#define HOSTFS_SUPER_MAGIC 0x00c0ffee -#define OVERLAYFS_SUPER_MAGIC 0x794c7630 - -#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ -#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ #define MINIX2_SUPER_MAGIC20x2478 /* minix v2 fs, 30 char names */ #define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */ - +#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ +#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ +#define MTD_INODE_FS_MAGIC 0x11307854 #define NCP_SUPER_MAGIC0x564c /* Guess, what 0x564c is :-) */ #define NFS_SUPER_MAGIC0x6969 +#define NILFS_SUPER_MAGIC 0x3434 +#define NSFS_MAGIC 0x6e736673 #define OPENPROM_SUPER_MAGIC 0x9fa1 +#define OVERLAYFS_SUPER_MAGIC 0x794c7630 +#define PIPEFS_MAGIC 0x50495045 +#define PROC_SUPER_MAGIC 0x9fa0 +#define PSTOREFS_MAGIC 0x6165676C #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ #define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */ - +#define RAMFS_MAGIC0x858458f6 /* some random number */ +#define RDTGROUP_SUPER_MAGIC 0x7655821 +#define REISER2FS_JR_SUPER_MAGIC_STRING"ReIsEr3Fs" +#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ - /* used by file system utilities that - look at the superblock, etc. */ #define REISERFS_SUPER_MAGIC_STRING"ReIsErFs" -#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" -#define REISER2FS_JR_SUPER_MAGIC_STRING"ReIsEr3Fs" - +#define SECURITYFS_MAGIC 0x73636673 +#define SELINUX_MAGIC 0xf97cff8c +#define SMACK_MAGIC0x43415d53 /* "SMAC" */ #define SMB_SUPER_MAGIC0x517B -#define CGROUP_SUPER_MAGIC 0x27e0eb -#define CGROUP2_SUPER_MAGIC0x63677270 - -#define RDTGROUP_SUPER_MAGIC
[PATCH 01/11 linux-next] uapi: reorganize magic.h
-Sort magic.h in alphabetical order as there were no real logic in this file. -Replace all spaces with tabs -Remove excessive comments for reiserfs Signed-off-by: Fabian Frederick --- include/uapi/linux/magic.h | 92 -- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e230af2..e3bb43b 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -3,86 +3,74 @@ #define ADFS_SUPER_MAGIC 0xadf5 #define AFFS_SUPER_MAGIC 0xadff -#define AFS_SUPER_MAGIC0x5346414F +#define AFS_SUPER_MAGIC0x5346414F +#define ANON_INODE_FS_MAGIC0x09041934 #define AUTOFS_SUPER_MAGIC 0x0187 +#define BALLOON_KVM_MAGIC 0x13661366 +#define BDEVFS_MAGIC 0x62646576 +#define BINFMTFS_MAGIC 0x42494e4d +#define BPF_FS_MAGIC 0xcafe4a11 +#define BTRFS_SUPER_MAGIC 0x9123683E +#define BTRFS_TEST_MAGIC 0x73727279 +#define CGROUP2_SUPER_MAGIC0x63677270 +#define CGROUP_SUPER_MAGIC 0x27e0eb #define CODA_SUPER_MAGIC 0x73757245 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */ #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */ -#define DEBUGFS_MAGIC 0x64626720 -#define SECURITYFS_MAGIC 0x73636673 -#define SELINUX_MAGIC 0xf97cff8c -#define SMACK_MAGIC0x43415d53 /* "SMAC" */ -#define RAMFS_MAGIC0x858458f6 /* some random number */ -#define TMPFS_MAGIC0x01021994 -#define HUGETLBFS_MAGIC0x958458f6 /* some random number */ -#define SQUASHFS_MAGIC 0x73717368 +#define DAXFS_MAGIC0x64646178 +#define DEBUGFS_MAGIC 0x64626720 +#define DEVPTS_SUPER_MAGIC 0x1cd1 #define ECRYPTFS_SUPER_MAGIC 0xf15f +#define EFIVARFS_MAGIC 0xde5e81e4 #define EFS_SUPER_MAGIC0x414A53 #define EXT2_SUPER_MAGIC 0xEF53 #define EXT3_SUPER_MAGIC 0xEF53 -#define XENFS_SUPER_MAGIC 0xabba1974 #define EXT4_SUPER_MAGIC 0xEF53 -#define BTRFS_SUPER_MAGIC 0x9123683E -#define NILFS_SUPER_MAGIC 0x3434 #define F2FS_SUPER_MAGIC 0xF2F52010 +#define FUTEXFS_SUPER_MAGIC0xBAD1DEA +#define HOSTFS_SUPER_MAGIC 0x00c0ffee #define HPFS_SUPER_MAGIC 0xf995e849 +#define HUGETLBFS_MAGIC0x958458f6 /* some random number */ #define ISOFS_SUPER_MAGIC 0x9660 #define JFFS2_SUPER_MAGIC 0x72b6 -#define PSTOREFS_MAGIC 0x6165676C -#define EFIVARFS_MAGIC 0xde5e81e4 -#define HOSTFS_SUPER_MAGIC 0x00c0ffee -#define OVERLAYFS_SUPER_MAGIC 0x794c7630 - -#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ -#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2 fs, 14 char names */ #define MINIX2_SUPER_MAGIC20x2478 /* minix v2 fs, 30 char names */ #define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */ - +#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */ +#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */ #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */ +#define MTD_INODE_FS_MAGIC 0x11307854 #define NCP_SUPER_MAGIC0x564c /* Guess, what 0x564c is :-) */ #define NFS_SUPER_MAGIC0x6969 +#define NILFS_SUPER_MAGIC 0x3434 +#define NSFS_MAGIC 0x6e736673 #define OPENPROM_SUPER_MAGIC 0x9fa1 +#define OVERLAYFS_SUPER_MAGIC 0x794c7630 +#define PIPEFS_MAGIC 0x50495045 +#define PROC_SUPER_MAGIC 0x9fa0 +#define PSTOREFS_MAGIC 0x6165676C #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */ #define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */ - +#define RAMFS_MAGIC0x858458f6 /* some random number */ +#define RDTGROUP_SUPER_MAGIC 0x7655821 +#define REISER2FS_JR_SUPER_MAGIC_STRING"ReIsEr3Fs" +#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */ - /* used by file system utilities that - look at the superblock, etc. */ #define REISERFS_SUPER_MAGIC_STRING"ReIsErFs" -#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" -#define REISER2FS_JR_SUPER_MAGIC_STRING"ReIsEr3Fs" - +#define SECURITYFS_MAGIC 0x73636673 +#define SELINUX_MAGIC 0xf97cff8c +#define SMACK_MAGIC0x43415d53 /* "SMAC" */ #define SMB_SUPER_MAGIC0x517B -#define CGROUP_SUPER_MAGIC 0x27e0eb -#define CGROUP2_SUPER_MAGIC0x63677270 - -#define RDTGROUP_SUPER_MAGIC 0x7655821 - -#def
[PATCH 02/11 linux-next] exofs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/exofs/common.h | 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/exofs/common.h b/fs/exofs/common.h index 7d88ef5..fb988f9 100644 --- a/fs/exofs/common.h +++ b/fs/exofs/common.h @@ -37,6 +37,7 @@ #define __EXOFS_COM_H__ #include +#include #include #include @@ -79,11 +80,6 @@ enum { #define EXOFS_BLKSHIFT 12 #define EXOFS_BLKSIZE (1UL << EXOFS_BLKSHIFT) -/ - * superblock-related things - / -#define EXOFS_SUPER_MAGIC 0x5DF5 - /* * The file system control block - stored in object EXOFS_SUPER_ID's data. * This is where the in-memory superblock is stored on disk. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e3bb43b..1265355 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -26,6 +26,7 @@ #define EXT2_SUPER_MAGIC 0xEF53 #define EXT3_SUPER_MAGIC 0xEF53 #define EXT4_SUPER_MAGIC 0xEF53 +#define EXOFS_SUPER_MAGIC 0x5DF5 #define F2FS_SUPER_MAGIC 0xF2F52010 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HOSTFS_SUPER_MAGIC 0x00c0ffee -- 2.9.3
[PATCH 02/11 linux-next] exofs: use magic.h
Filesystems generally use SUPER_MAGIC values from magic.h instead of a local definition. Signed-off-by: Fabian Frederick --- fs/exofs/common.h | 6 +- include/uapi/linux/magic.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/exofs/common.h b/fs/exofs/common.h index 7d88ef5..fb988f9 100644 --- a/fs/exofs/common.h +++ b/fs/exofs/common.h @@ -37,6 +37,7 @@ #define __EXOFS_COM_H__ #include +#include #include #include @@ -79,11 +80,6 @@ enum { #define EXOFS_BLKSHIFT 12 #define EXOFS_BLKSIZE (1UL << EXOFS_BLKSHIFT) -/ - * superblock-related things - / -#define EXOFS_SUPER_MAGIC 0x5DF5 - /* * The file system control block - stored in object EXOFS_SUPER_ID's data. * This is where the in-memory superblock is stored on disk. diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index e3bb43b..1265355 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -26,6 +26,7 @@ #define EXT2_SUPER_MAGIC 0xEF53 #define EXT3_SUPER_MAGIC 0xEF53 #define EXT4_SUPER_MAGIC 0xEF53 +#define EXOFS_SUPER_MAGIC 0x5DF5 #define F2FS_SUPER_MAGIC 0xF2F52010 #define FUTEXFS_SUPER_MAGIC0xBAD1DEA #define HOSTFS_SUPER_MAGIC 0x00c0ffee -- 2.9.3
[PATCH 00/11 linux-next] super magic values consolidation
This small patchset reorganizes magic.h and fixes filesystems which defined locally super magic values. Fabian Frederick (11): uapi: reorganize magic.h exofs: use magic.h ceph: use magic.h orangefs: use magic.h ubifs: use magic.h jfs: use magic.h ocfs2: use magic.h fuse: use magic.h freevxfs: use magic.h fs: define hfs super magic values globally hfsplus: export super magic value fs/ceph/super.h| 4 +- fs/exofs/common.h | 6 +-- fs/freevxfs/vxfs.h | 6 +-- fs/fuse/control.c | 3 +- fs/fuse/inode.c| 3 +- fs/hfs/hfs.h | 4 +- fs/hfsplus/hfsplus_raw.h | 2 +- fs/hfsplus/part_tbl.c | 2 - fs/jfs/jfs_incore.h| 6 +-- fs/ocfs2/ocfs2_fs.h| 5 +-- fs/orangefs/protocol.h | 3 +- fs/ubifs/ubifs.h | 4 +- include/uapi/linux/magic.h | 104 ++--- 13 files changed, 65 insertions(+), 87 deletions(-) -- 2.9.3
[PATCH 00/11 linux-next] super magic values consolidation
This small patchset reorganizes magic.h and fixes filesystems which defined locally super magic values. Fabian Frederick (11): uapi: reorganize magic.h exofs: use magic.h ceph: use magic.h orangefs: use magic.h ubifs: use magic.h jfs: use magic.h ocfs2: use magic.h fuse: use magic.h freevxfs: use magic.h fs: define hfs super magic values globally hfsplus: export super magic value fs/ceph/super.h| 4 +- fs/exofs/common.h | 6 +-- fs/freevxfs/vxfs.h | 6 +-- fs/fuse/control.c | 3 +- fs/fuse/inode.c| 3 +- fs/hfs/hfs.h | 4 +- fs/hfsplus/hfsplus_raw.h | 2 +- fs/hfsplus/part_tbl.c | 2 - fs/jfs/jfs_incore.h| 6 +-- fs/ocfs2/ocfs2_fs.h| 5 +-- fs/orangefs/protocol.h | 3 +- fs/ubifs/ubifs.h | 4 +- include/uapi/linux/magic.h | 104 ++--- 13 files changed, 65 insertions(+), 87 deletions(-) -- 2.9.3
[PATCH linux-next] fs: remove void * casting in init_once()
See Documentation/process/coding-style.rst: "Casting the return value which is a void pointer is redundant. The conversion from void pointer to any other pointer type is guaranteed by the C programming language." This will stop copy/paste cascade warnings. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/9p/v9fs.c | 2 +- fs/adfs/super.c | 2 +- fs/affs/super.c | 2 +- fs/befs/linuxvfs.c| 2 +- fs/block_dev.c| 2 +- fs/btrfs/inode.c | 2 +- fs/coda/inode.c | 2 +- fs/ecryptfs/main.c| 2 +- fs/efs/super.c| 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fat/cache.c| 2 +- fs/fat/inode.c| 2 +- fs/hpfs/super.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/inode.c| 2 +- fs/jfs/super.c| 2 +- fs/minix/inode.c | 2 +- fs/ncpfs/inode.c | 2 +- fs/nfs/inode.c| 2 +- fs/ntfs/super.c | 2 +- fs/openpromfs/inode.c | 2 +- fs/proc/inode.c | 2 +- fs/qnx6/inode.c | 2 +- fs/reiserfs/super.c | 2 +- fs/sysv/inode.c | 2 +- fs/udf/super.c| 2 +- fs/ufs/super.c| 2 +- fs/userfaultfd.c | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index c202930..eedc055 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -551,7 +551,7 @@ static void v9fs_sysfs_cleanup(void) static void v9fs_inode_init_once(void *foo) { - struct v9fs_inode *v9inode = (struct v9fs_inode *)foo; + struct v9fs_inode *v9inode = foo; #ifdef CONFIG_9P_FSCACHE v9inode->fscache = NULL; #endif diff --git a/fs/adfs/super.c b/fs/adfs/super.c index c9fdfb1..f5b1a91 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -261,7 +261,7 @@ static void adfs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; + struct adfs_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/affs/super.c b/fs/affs/super.c index c2c27a8..3e3aa22 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -121,7 +121,7 @@ static void affs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct affs_inode_info *ei = (struct affs_inode_info *) foo; + struct affs_inode_info *ei = foo; sema_init(>i_link_lock, 1); sema_init(>i_ext_lock, 1); diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 63e7c47..1872d2af 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -299,7 +299,7 @@ static void befs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct befs_inode_info *bi = (struct befs_inode_info *) foo; + struct befs_inode_info *bi = foo; inode_init_once(>vfs_inode); } diff --git a/fs/block_dev.c b/fs/block_dev.c index 519599d..0c19bbc 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -747,7 +747,7 @@ static void bdev_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct bdev_inode *ei = (struct bdev_inode *) foo; + struct bdev_inode *ei = foo; struct block_device *bdev = >bdev; memset(bdev, 0, sizeof(*bdev)); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 337aef8..e51e8ee 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9520,7 +9520,7 @@ int btrfs_drop_inode(struct inode *inode) static void init_once(void *foo) { - struct btrfs_inode *ei = (struct btrfs_inode *) foo; + struct btrfs_inode *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 6058df3..15e0ec4 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -66,7 +66,7 @@ static void coda_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct coda_inode_info *ei = (struct coda_inode_info *) foo; + struct coda_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 21a909d..3b74b81 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -652,7 +652,7 @@ MODULE_ALIAS_FS("ecryptfs"); static void inode_info_init_once(void *vptr) { - struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; + struct ecryptfs_inode_info *ei = vptr; inode_init_once(>vfs_inode); } diff --git a/fs/efs/super.c b/fs/efs/super.c index 368f7dd..1ffb755 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c @@ -86,7 +86,7 @@ static void efs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct efs_inode_info *ei = (struct efs_inode_info *) foo; + struct efs_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 9c2028b..edd0e2d 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -204,7 +204,7 @@ static voi
[PATCH linux-next] fs: remove void * casting in init_once()
See Documentation/process/coding-style.rst: "Casting the return value which is a void pointer is redundant. The conversion from void pointer to any other pointer type is guaranteed by the C programming language." This will stop copy/paste cascade warnings. Signed-off-by: Fabian Frederick --- fs/9p/v9fs.c | 2 +- fs/adfs/super.c | 2 +- fs/affs/super.c | 2 +- fs/befs/linuxvfs.c| 2 +- fs/block_dev.c| 2 +- fs/btrfs/inode.c | 2 +- fs/coda/inode.c | 2 +- fs/ecryptfs/main.c| 2 +- fs/efs/super.c| 2 +- fs/ext2/super.c | 2 +- fs/ext4/super.c | 2 +- fs/f2fs/super.c | 2 +- fs/fat/cache.c| 2 +- fs/fat/inode.c| 2 +- fs/hpfs/super.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/inode.c| 2 +- fs/jfs/super.c| 2 +- fs/minix/inode.c | 2 +- fs/ncpfs/inode.c | 2 +- fs/nfs/inode.c| 2 +- fs/ntfs/super.c | 2 +- fs/openpromfs/inode.c | 2 +- fs/proc/inode.c | 2 +- fs/qnx6/inode.c | 2 +- fs/reiserfs/super.c | 2 +- fs/sysv/inode.c | 2 +- fs/udf/super.c| 2 +- fs/ufs/super.c| 2 +- fs/userfaultfd.c | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index c202930..eedc055 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -551,7 +551,7 @@ static void v9fs_sysfs_cleanup(void) static void v9fs_inode_init_once(void *foo) { - struct v9fs_inode *v9inode = (struct v9fs_inode *)foo; + struct v9fs_inode *v9inode = foo; #ifdef CONFIG_9P_FSCACHE v9inode->fscache = NULL; #endif diff --git a/fs/adfs/super.c b/fs/adfs/super.c index c9fdfb1..f5b1a91 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -261,7 +261,7 @@ static void adfs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; + struct adfs_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/affs/super.c b/fs/affs/super.c index c2c27a8..3e3aa22 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -121,7 +121,7 @@ static void affs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct affs_inode_info *ei = (struct affs_inode_info *) foo; + struct affs_inode_info *ei = foo; sema_init(>i_link_lock, 1); sema_init(>i_ext_lock, 1); diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 63e7c47..1872d2af 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -299,7 +299,7 @@ static void befs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct befs_inode_info *bi = (struct befs_inode_info *) foo; + struct befs_inode_info *bi = foo; inode_init_once(>vfs_inode); } diff --git a/fs/block_dev.c b/fs/block_dev.c index 519599d..0c19bbc 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -747,7 +747,7 @@ static void bdev_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct bdev_inode *ei = (struct bdev_inode *) foo; + struct bdev_inode *ei = foo; struct block_device *bdev = >bdev; memset(bdev, 0, sizeof(*bdev)); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 337aef8..e51e8ee 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9520,7 +9520,7 @@ int btrfs_drop_inode(struct inode *inode) static void init_once(void *foo) { - struct btrfs_inode *ei = (struct btrfs_inode *) foo; + struct btrfs_inode *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 6058df3..15e0ec4 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -66,7 +66,7 @@ static void coda_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct coda_inode_info *ei = (struct coda_inode_info *) foo; + struct coda_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 21a909d..3b74b81 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c @@ -652,7 +652,7 @@ MODULE_ALIAS_FS("ecryptfs"); static void inode_info_init_once(void *vptr) { - struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; + struct ecryptfs_inode_info *ei = vptr; inode_init_once(>vfs_inode); } diff --git a/fs/efs/super.c b/fs/efs/super.c index 368f7dd..1ffb755 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c @@ -86,7 +86,7 @@ static void efs_destroy_inode(struct inode *inode) static void init_once(void *foo) { - struct efs_inode_info *ei = (struct efs_inode_info *) foo; + struct efs_inode_info *ei = foo; inode_init_once(>vfs_inode); } diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 9c2028b..edd0e2d 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -204,7 +204,7 @@ static void ext2_destroy_inode(
[PATCH 3/3 linux-next] fs/affs: stat: return block number
stat doesn't give any block number as it's filesystem specific. Add getattr wrapper to return i_blkcnt calculated during affs_iget() Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/affs.h | 2 ++ fs/affs/file.c | 1 + fs/affs/inode.c | 11 +++ 3 files changed, 14 insertions(+) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index fd99f28..a2151e9 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -180,6 +180,8 @@ extern int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, /* inode.c */ extern struct inode *affs_new_inode(struct inode *dir); +extern int affs_getattr(const struct path *path, struct kstat *stat, +u32 request_mask, unsigned int flags); extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); extern voidaffs_evict_inode(struct inode *inode); extern struct inode *affs_iget(struct super_block *sb, unsigned long ino); diff --git a/fs/affs/file.c b/fs/affs/file.c index 196ee7f..b331abb 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -979,4 +979,5 @@ const struct file_operations affs_file_operations = { const struct inode_operations affs_file_inode_operations = { .setattr= affs_notify_change, + .getattr= affs_getattr, }; diff --git a/fs/affs/inode.c b/fs/affs/inode.c index fd4ef3c..76fb281 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -214,6 +214,17 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) return 0; } +int affs_getattr(const struct path *path, struct kstat *stat, +u32 request_mask, unsigned int flags) +{ + struct inode *inode = d_inode(path->dentry); + + generic_fillattr(inode, stat); + stat->blocks = AFFS_I(inode)->i_blkcnt; + + return 0; +} + int affs_notify_change(struct dentry *dentry, struct iattr *attr) { -- 2.9.3
[PATCH 3/3 linux-next] fs/affs: stat: return block number
stat doesn't give any block number as it's filesystem specific. Add getattr wrapper to return i_blkcnt calculated during affs_iget() Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 2 ++ fs/affs/file.c | 1 + fs/affs/inode.c | 11 +++ 3 files changed, 14 insertions(+) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index fd99f28..a2151e9 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -180,6 +180,8 @@ extern int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, /* inode.c */ extern struct inode *affs_new_inode(struct inode *dir); +extern int affs_getattr(const struct path *path, struct kstat *stat, +u32 request_mask, unsigned int flags); extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); extern voidaffs_evict_inode(struct inode *inode); extern struct inode *affs_iget(struct super_block *sb, unsigned long ino); diff --git a/fs/affs/file.c b/fs/affs/file.c index 196ee7f..b331abb 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -979,4 +979,5 @@ const struct file_operations affs_file_operations = { const struct inode_operations affs_file_inode_operations = { .setattr= affs_notify_change, + .getattr= affs_getattr, }; diff --git a/fs/affs/inode.c b/fs/affs/inode.c index fd4ef3c..76fb281 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -214,6 +214,17 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) return 0; } +int affs_getattr(const struct path *path, struct kstat *stat, +u32 request_mask, unsigned int flags) +{ + struct inode *inode = d_inode(path->dentry); + + generic_fillattr(inode, stat); + stat->blocks = AFFS_I(inode)->i_blkcnt; + + return 0; +} + int affs_notify_change(struct dentry *dentry, struct iattr *attr) { -- 2.9.3
[PATCH 2/3 linux-next] fs/affs: remove affs_set_blocksize()
That function was only calling sb_set_blocksize() Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/affs.h | 5 - fs/affs/super.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 87b17b5..fd99f28 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -219,11 +219,6 @@ static inline bool affs_validblock(struct super_block *sb, int block) block < AFFS_SB(sb)->s_partition_size); } -static inline void -affs_set_blocksize(struct super_block *sb, int size) -{ - sb_set_blocksize(sb, size); -} static inline struct buffer_head * affs_bread(struct super_block *sb, int block) { diff --git a/fs/affs/super.c b/fs/affs/super.c index c2c27a8..2c0e607 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -357,7 +357,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) size = i_size_read(sb->s_bdev->bd_inode) >> 9; pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size); - affs_set_blocksize(sb, PAGE_SIZE); + sb_set_blocksize(sb, PAGE_SIZE); /* Try to find root block. Its location depends on the block size. */ i = bdev_logical_block_size(sb->s_bdev); @@ -372,7 +372,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) if (root_block < 0) sbi->s_root_block = (reserved + size - 1) / 2; pr_debug("setting blocksize to %d\n", blocksize); - affs_set_blocksize(sb, blocksize); + sb_set_blocksize(sb, blocksize); sbi->s_partition_size = size; /* The root block location that was calculated above is not -- 2.9.3
[PATCH 2/3 linux-next] fs/affs: remove affs_set_blocksize()
That function was only calling sb_set_blocksize() Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 5 - fs/affs/super.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 87b17b5..fd99f28 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -219,11 +219,6 @@ static inline bool affs_validblock(struct super_block *sb, int block) block < AFFS_SB(sb)->s_partition_size); } -static inline void -affs_set_blocksize(struct super_block *sb, int size) -{ - sb_set_blocksize(sb, size); -} static inline struct buffer_head * affs_bread(struct super_block *sb, int block) { diff --git a/fs/affs/super.c b/fs/affs/super.c index c2c27a8..2c0e607 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -357,7 +357,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) size = i_size_read(sb->s_bdev->bd_inode) >> 9; pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size); - affs_set_blocksize(sb, PAGE_SIZE); + sb_set_blocksize(sb, PAGE_SIZE); /* Try to find root block. Its location depends on the block size. */ i = bdev_logical_block_size(sb->s_bdev); @@ -372,7 +372,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) if (root_block < 0) sbi->s_root_block = (reserved + size - 1) / 2; pr_debug("setting blocksize to %d\n", blocksize); - affs_set_blocksize(sb, blocksize); + sb_set_blocksize(sb, blocksize); sbi->s_partition_size = size; /* The root block location that was calculated above is not -- 2.9.3
[PATCH 1/3 linux-next] fs/affs: normalize inode function prototypes
Use the same style as other function blocks Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/affs.h | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 773749b..87b17b5 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -179,14 +179,14 @@ extern intaffs_rename2(struct inode *old_dir, struct dentry *old_dentry, /* inode.c */ -extern struct inode*affs_new_inode(struct inode *dir); -extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); -extern void affs_evict_inode(struct inode *inode); -extern struct inode*affs_iget(struct super_block *sb, - unsigned long ino); -extern int affs_write_inode(struct inode *inode, - struct writeback_control *wbc); -extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type); +extern struct inode *affs_new_inode(struct inode *dir); +extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); +extern voidaffs_evict_inode(struct inode *inode); +extern struct inode *affs_iget(struct super_block *sb, unsigned long ino); +extern int affs_write_inode(struct inode *inode, +struct writeback_control *wbc); +extern int affs_add_entry(struct inode *dir, struct inode *inode, + struct dentry *dentry, s32 type); /* file.c */ -- 2.9.3
[PATCH 1/3 linux-next] fs/affs: normalize inode function prototypes
Use the same style as other function blocks Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index 773749b..87b17b5 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -179,14 +179,14 @@ extern intaffs_rename2(struct inode *old_dir, struct dentry *old_dentry, /* inode.c */ -extern struct inode*affs_new_inode(struct inode *dir); -extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); -extern void affs_evict_inode(struct inode *inode); -extern struct inode*affs_iget(struct super_block *sb, - unsigned long ino); -extern int affs_write_inode(struct inode *inode, - struct writeback_control *wbc); -extern int affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type); +extern struct inode *affs_new_inode(struct inode *dir); +extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); +extern voidaffs_evict_inode(struct inode *inode); +extern struct inode *affs_iget(struct super_block *sb, unsigned long ino); +extern int affs_write_inode(struct inode *inode, +struct writeback_control *wbc); +extern int affs_add_entry(struct inode *dir, struct inode *inode, + struct dentry *dentry, s32 type); /* file.c */ -- 2.9.3
[PATCH 0/3 linux-next] fs/affs: add blocknumber to stat
stat doesn't give any block number as it's filesystem specific. This small patchset adds getattr wrapper to return i_blkcnt calculated during affs_iget() and does some clean-up in affs.h Fabian Frederick (3): fs/affs: normalize inode function prototypes fs/affs: remove affs_set_blocksize() fs/affs: stat: return block number fs/affs/affs.h | 23 ++- fs/affs/file.c | 1 + fs/affs/inode.c | 11 +++ fs/affs/super.c | 4 ++-- 4 files changed, 24 insertions(+), 15 deletions(-) -- 2.9.3
[PATCH 0/3 linux-next] fs/affs: add blocknumber to stat
stat doesn't give any block number as it's filesystem specific. This small patchset adds getattr wrapper to return i_blkcnt calculated during affs_iget() and does some clean-up in affs.h Fabian Frederick (3): fs/affs: normalize inode function prototypes fs/affs: remove affs_set_blocksize() fs/affs: stat: return block number fs/affs/affs.h | 23 ++- fs/affs/file.c | 1 + fs/affs/inode.c | 11 +++ fs/affs/super.c | 4 ++-- 4 files changed, 24 insertions(+), 15 deletions(-) -- 2.9.3
[PATCH linux-next] device-dax: fix BLOCK dependency
commit ef51042472f5 ("block, dax: move "select DAX" from BLOCK to FS_DAX") uses get_start_sect() which requires CONFIG_BLOCK make allnoconfig + dax gives the following: drivers/dax/super.c: In function 'bdev_dax_pgoff': drivers/dax/super.c:50:26: error: implicit declaration of function 'get_start_sect' [-Werror=implicit-function-declaration] Signed-off-by: Fabian Frederick <f...@skynet.be> --- drivers/dax/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index b79aa8f..1806628 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -1,5 +1,6 @@ menuconfig DAX tristate "DAX: direct access to differentiated memory" + depends on BLOCK select SRCU default m if NVDIMM_DAX -- 2.9.3
[PATCH linux-next] device-dax: fix BLOCK dependency
commit ef51042472f5 ("block, dax: move "select DAX" from BLOCK to FS_DAX") uses get_start_sect() which requires CONFIG_BLOCK make allnoconfig + dax gives the following: drivers/dax/super.c: In function 'bdev_dax_pgoff': drivers/dax/super.c:50:26: error: implicit declaration of function 'get_start_sect' [-Werror=implicit-function-declaration] Signed-off-by: Fabian Frederick --- drivers/dax/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index b79aa8f..1806628 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -1,5 +1,6 @@ menuconfig DAX tristate "DAX: direct access to differentiated memory" + depends on BLOCK select SRCU default m if NVDIMM_DAX -- 2.9.3
[PATCH linux-next] jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
Use kcalloc() for allocation/flush of 128 pointers table to reduce stack usage. Function now returns -ENOMEM or 0 on success. stackusage Before: ./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208 dynamic,bounded After: ./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192 dynamic,bounded Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled Tested with an MTD mount point and some user set/getfattr. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/jffs2/build.c | 5 - fs/jffs2/xattr.c | 14 ++ fs/jffs2/xattr.h | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index b288c8a..f88e0bf 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c @@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ic->scan_dents = NULL; cond_resched(); } - jffs2_build_xattr_subsystem(c); + ret = jffs2_build_xattr_subsystem(c); + if (ret) + goto exit; + c->flags &= ~JFFS2_SB_FLAG_BUILDING; dbg_fsbuild("FS build complete\n"); diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index da3e185..95c0496 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c @@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c) } #define XREF_TMPHASH_SIZE (128) -void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) +int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) { struct jffs2_xattr_ref *ref, *_ref; - struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE]; + struct jffs2_xattr_ref **xref_tmphash; struct jffs2_xattr_datum *xd, *_xd; struct jffs2_inode_cache *ic; struct jffs2_raw_node_ref *raw; @@ -784,9 +784,13 @@ void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING)); + + xref_tmphash = kcalloc(XREF_TMPHASH_SIZE, + sizeof(struct jffs2_xattr_ref *), GFP_KERNEL); + if (!xref_tmphash) + return -ENOMEM; + /* Phase.1 : Merge same xref */ - for (i=0; i < XREF_TMPHASH_SIZE; i++) - xref_tmphash[i] = NULL; for (ref=c->xref_temp; ref; ref=_ref) { struct jffs2_xattr_ref *tmp; @@ -884,6 +888,8 @@ void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) "%u of xref (%u dead, %u orphan) found.\n", xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, xref_count, xref_dead_count, xref_orphan_count); + kfree(xref_tmphash); + return 0; } struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h index 720007b..1b5030a 100644 --- a/fs/jffs2/xattr.h +++ b/fs/jffs2/xattr.h @@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref) #ifdef CONFIG_JFFS2_FS_XATTR extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); -extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); +extern int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, @@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); #else #define jffs2_init_xattr_subsystem(c) -#define jffs2_build_xattr_subsystem(c) +#define jffs2_build_xattr_subsystem(c) (0) #define jffs2_clear_xattr_subsystem(c) #define jffs2_xattr_do_crccheck_inode(c, ic) -- 2.9.3
[PATCH linux-next] jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
Use kcalloc() for allocation/flush of 128 pointers table to reduce stack usage. Function now returns -ENOMEM or 0 on success. stackusage Before: ./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208 dynamic,bounded After: ./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192 dynamic,bounded Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled Tested with an MTD mount point and some user set/getfattr. Signed-off-by: Fabian Frederick --- fs/jffs2/build.c | 5 - fs/jffs2/xattr.c | 14 ++ fs/jffs2/xattr.h | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index b288c8a..f88e0bf 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c @@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c) ic->scan_dents = NULL; cond_resched(); } - jffs2_build_xattr_subsystem(c); + ret = jffs2_build_xattr_subsystem(c); + if (ret) + goto exit; + c->flags &= ~JFFS2_SB_FLAG_BUILDING; dbg_fsbuild("FS build complete\n"); diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index da3e185..95c0496 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c @@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c) } #define XREF_TMPHASH_SIZE (128) -void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) +int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) { struct jffs2_xattr_ref *ref, *_ref; - struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE]; + struct jffs2_xattr_ref **xref_tmphash; struct jffs2_xattr_datum *xd, *_xd; struct jffs2_inode_cache *ic; struct jffs2_raw_node_ref *raw; @@ -784,9 +784,13 @@ void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING)); + + xref_tmphash = kcalloc(XREF_TMPHASH_SIZE, + sizeof(struct jffs2_xattr_ref *), GFP_KERNEL); + if (!xref_tmphash) + return -ENOMEM; + /* Phase.1 : Merge same xref */ - for (i=0; i < XREF_TMPHASH_SIZE; i++) - xref_tmphash[i] = NULL; for (ref=c->xref_temp; ref; ref=_ref) { struct jffs2_xattr_ref *tmp; @@ -884,6 +888,8 @@ void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c) "%u of xref (%u dead, %u orphan) found.\n", xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, xref_count, xref_dead_count, xref_orphan_count); + kfree(xref_tmphash); + return 0; } struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h index 720007b..1b5030a 100644 --- a/fs/jffs2/xattr.h +++ b/fs/jffs2/xattr.h @@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref) #ifdef CONFIG_JFFS2_FS_XATTR extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c); -extern void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); +extern int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c); extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, @@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); #else #define jffs2_init_xattr_subsystem(c) -#define jffs2_build_xattr_subsystem(c) +#define jffs2_build_xattr_subsystem(c) (0) #define jffs2_clear_xattr_subsystem(c) #define jffs2_xattr_do_crccheck_inode(c, ic) -- 2.9.3
[PATCH 2/2 linux-next] fs/affs: add rename exchange
Process RENAME_EXCHANGE in affs_rename2() adding static affs_xrename() based on affs_rename(). We remove headers from respective directories then affect bh to other inode directory entries for swapping. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/namei.c | 58 - 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 49a8dc1..46d3ace 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -441,17 +441,73 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, return retval; } +static int +affs_xrename(struct inode *old_dir, struct dentry *old_dentry, +struct inode *new_dir, struct dentry *new_dentry) +{ + + struct super_block *sb = old_dir->i_sb; + struct buffer_head *bh_old = NULL; + struct buffer_head *bh_new = NULL; + int retval; + + bh_old = affs_bread(sb, d_inode(old_dentry)->i_ino); + if (!bh_old) + return -EIO; + + bh_new = affs_bread(sb, d_inode(new_dentry)->i_ino); + if (!bh_new) + return -EIO; + + /* Remove old header from its parent directory. */ + affs_lock_dir(old_dir); + retval = affs_remove_hash(old_dir, bh_old); + affs_unlock_dir(old_dir); + if (retval) + goto done; + + /* Remove new header from its parent directory. */ + affs_lock_dir(new_dir); + retval = affs_remove_hash(new_dir, bh_new); + affs_unlock_dir(new_dir); + if (retval) + goto done; + + /* Insert old into the new directory with the new name. */ + affs_copy_name(AFFS_TAIL(sb, bh_old)->name, new_dentry); + affs_fix_checksum(sb, bh_old); + affs_lock_dir(new_dir); + retval = affs_insert_hash(new_dir, bh_old); + affs_unlock_dir(new_dir); + + /* Insert new into the old directory with the old name. */ + affs_copy_name(AFFS_TAIL(sb, bh_new)->name, old_dentry); + affs_fix_checksum(sb, bh_new); + affs_lock_dir(old_dir); + retval = affs_insert_hash(old_dir, bh_new); + affs_unlock_dir(old_dir); +done: + mark_buffer_dirty_inode(bh_old, new_dir); + mark_buffer_dirty_inode(bh_new, old_dir); + affs_brelse(bh_old); + affs_brelse(bh_new); + return retval; +} + int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { - if (flags & ~RENAME_NOREPLACE) + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) return -EINVAL; pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); + if (flags & RENAME_EXCHANGE) + return affs_xrename(old_dir, old_dentry, new_dir, new_dentry); + return affs_rename(old_dir, old_dentry, new_dir, new_dentry); } -- 2.9.3
[PATCH 2/2 linux-next] fs/affs: add rename exchange
Process RENAME_EXCHANGE in affs_rename2() adding static affs_xrename() based on affs_rename(). We remove headers from respective directories then affect bh to other inode directory entries for swapping. Signed-off-by: Fabian Frederick --- fs/affs/namei.c | 58 - 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/fs/affs/namei.c b/fs/affs/namei.c index 49a8dc1..46d3ace 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -441,17 +441,73 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, return retval; } +static int +affs_xrename(struct inode *old_dir, struct dentry *old_dentry, +struct inode *new_dir, struct dentry *new_dentry) +{ + + struct super_block *sb = old_dir->i_sb; + struct buffer_head *bh_old = NULL; + struct buffer_head *bh_new = NULL; + int retval; + + bh_old = affs_bread(sb, d_inode(old_dentry)->i_ino); + if (!bh_old) + return -EIO; + + bh_new = affs_bread(sb, d_inode(new_dentry)->i_ino); + if (!bh_new) + return -EIO; + + /* Remove old header from its parent directory. */ + affs_lock_dir(old_dir); + retval = affs_remove_hash(old_dir, bh_old); + affs_unlock_dir(old_dir); + if (retval) + goto done; + + /* Remove new header from its parent directory. */ + affs_lock_dir(new_dir); + retval = affs_remove_hash(new_dir, bh_new); + affs_unlock_dir(new_dir); + if (retval) + goto done; + + /* Insert old into the new directory with the new name. */ + affs_copy_name(AFFS_TAIL(sb, bh_old)->name, new_dentry); + affs_fix_checksum(sb, bh_old); + affs_lock_dir(new_dir); + retval = affs_insert_hash(new_dir, bh_old); + affs_unlock_dir(new_dir); + + /* Insert new into the old directory with the old name. */ + affs_copy_name(AFFS_TAIL(sb, bh_new)->name, old_dentry); + affs_fix_checksum(sb, bh_new); + affs_lock_dir(old_dir); + retval = affs_insert_hash(old_dir, bh_new); + affs_unlock_dir(old_dir); +done: + mark_buffer_dirty_inode(bh_old, new_dir); + mark_buffer_dirty_inode(bh_new, old_dir); + affs_brelse(bh_old); + affs_brelse(bh_new); + return retval; +} + int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags) { - if (flags & ~RENAME_NOREPLACE) + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) return -EINVAL; pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); + if (flags & RENAME_EXCHANGE) + return affs_xrename(old_dir, old_dentry, new_dir, new_dentry); + return affs_rename(old_dir, old_dentry, new_dir, new_dentry); } -- 2.9.3
[PATCH 1/2 linux-next] fs/affs: add rename2 to prepare multiple methods
Currently AFFS only supports RENAME_NOREPLACE. This patch isolates that method to a static function to prepare RENAME_EXCHANGE addition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/affs.h | 2 +- fs/affs/dir.c | 2 +- fs/affs/namei.c | 25 - 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index ba26a31..773749b 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -173,7 +173,7 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir, struct dentry *dentry); extern int affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname); -extern int affs_rename(struct inode *old_dir, struct dentry *old_dentry, +extern int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); diff --git a/fs/affs/dir.c b/fs/affs/dir.c index f1e7294..591ecd7 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = { .symlink= affs_symlink, .mkdir = affs_mkdir, .rmdir = affs_rmdir, - .rename = affs_rename, + .rename = affs_rename2, .setattr= affs_notify_change, }; diff --git a/fs/affs/namei.c b/fs/affs/namei.c index d9a40b5..49a8dc1 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -394,21 +394,14 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) return affs_add_entry(dir, inode, dentry, ST_LINKFILE); } -int +static int affs_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry, - unsigned int flags) + struct inode *new_dir, struct dentry *new_dentry) { struct super_block *sb = old_dir->i_sb; struct buffer_head *bh = NULL; int retval; - if (flags & ~RENAME_NOREPLACE) - return -EINVAL; - - pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, -old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); - retval = affs_check_name(new_dentry->d_name.name, new_dentry->d_name.len, affs_nofilenametruncate(old_dentry)); @@ -448,6 +441,20 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, return retval; } +int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) +{ + + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + + pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, +old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); + + return affs_rename(old_dir, old_dentry, new_dir, new_dentry); +} + static struct dentry *affs_get_parent(struct dentry *child) { struct inode *parent; -- 2.9.3
[PATCH 1/2 linux-next] fs/affs: add rename2 to prepare multiple methods
Currently AFFS only supports RENAME_NOREPLACE. This patch isolates that method to a static function to prepare RENAME_EXCHANGE addition. Signed-off-by: Fabian Frederick --- fs/affs/affs.h | 2 +- fs/affs/dir.c | 2 +- fs/affs/namei.c | 25 - 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/affs/affs.h b/fs/affs/affs.h index ba26a31..773749b 100644 --- a/fs/affs/affs.h +++ b/fs/affs/affs.h @@ -173,7 +173,7 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir, struct dentry *dentry); extern int affs_symlink(struct inode *dir, struct dentry *dentry, const char *symname); -extern int affs_rename(struct inode *old_dir, struct dentry *old_dentry, +extern int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); diff --git a/fs/affs/dir.c b/fs/affs/dir.c index f1e7294..591ecd7 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -35,7 +35,7 @@ const struct inode_operations affs_dir_inode_operations = { .symlink= affs_symlink, .mkdir = affs_mkdir, .rmdir = affs_rmdir, - .rename = affs_rename, + .rename = affs_rename2, .setattr= affs_notify_change, }; diff --git a/fs/affs/namei.c b/fs/affs/namei.c index d9a40b5..49a8dc1 100644 --- a/fs/affs/namei.c +++ b/fs/affs/namei.c @@ -394,21 +394,14 @@ affs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) return affs_add_entry(dir, inode, dentry, ST_LINKFILE); } -int +static int affs_rename(struct inode *old_dir, struct dentry *old_dentry, - struct inode *new_dir, struct dentry *new_dentry, - unsigned int flags) + struct inode *new_dir, struct dentry *new_dentry) { struct super_block *sb = old_dir->i_sb; struct buffer_head *bh = NULL; int retval; - if (flags & ~RENAME_NOREPLACE) - return -EINVAL; - - pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, -old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); - retval = affs_check_name(new_dentry->d_name.name, new_dentry->d_name.len, affs_nofilenametruncate(old_dentry)); @@ -448,6 +441,20 @@ affs_rename(struct inode *old_dir, struct dentry *old_dentry, return retval; } +int affs_rename2(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry, + unsigned int flags) +{ + + if (flags & ~RENAME_NOREPLACE) + return -EINVAL; + + pr_debug("%s(old=%lu,\"%pd\" to new=%lu,\"%pd\")\n", __func__, +old_dir->i_ino, old_dentry, new_dir->i_ino, new_dentry); + + return affs_rename(old_dir, old_dentry, new_dir, new_dentry); +} + static struct dentry *affs_get_parent(struct dentry *child) { struct inode *parent; -- 2.9.3
[PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()
This script removes NULL check on kmap() and all process involved (OOM message ...) Thanks to Jan Kara for explanations. Acked-by: Julia Lawall <julia.law...@lip6.fr> Signed-off-by: Fabian Frederick <f...@skynet.be> --- scripts/coccinelle/misc/kmap.cocci | 43 ++ 1 file changed, 43 insertions(+) create mode 100644 scripts/coccinelle/misc/kmap.cocci diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci new file mode 100644 index 000..9ae4a6e --- /dev/null +++ b/scripts/coccinelle/misc/kmap.cocci @@ -0,0 +1,43 @@ +/// kmap never fails; remove NULL test case. +/// +// Copyright: (C) 2017 Fabian Frederick. GPLv2. +// Comments: - +// Options: --no-includes --include-headers + +virtual patch +virtual org +virtual report +virtual context + +@r2 depends on patch@ +expression E; +position p; +@@ + +E = kmap(...); +- if (!E) { +- ... +- } + +@r depends on context || report || org @ +expression E; +position p; +@@ + +* E = kmap(...); +* if (@p!E) { +* ... +* } + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "WARNING: NULL check on kmap() result is not needed." +coccilib.report.print_report(p[0], msg) -- 2.9.3
[PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()
This script removes NULL check on kmap() and all process involved (OOM message ...) Thanks to Jan Kara for explanations. Acked-by: Julia Lawall Signed-off-by: Fabian Frederick --- scripts/coccinelle/misc/kmap.cocci | 43 ++ 1 file changed, 43 insertions(+) create mode 100644 scripts/coccinelle/misc/kmap.cocci diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci new file mode 100644 index 000..9ae4a6e --- /dev/null +++ b/scripts/coccinelle/misc/kmap.cocci @@ -0,0 +1,43 @@ +/// kmap never fails; remove NULL test case. +/// +// Copyright: (C) 2017 Fabian Frederick. GPLv2. +// Comments: - +// Options: --no-includes --include-headers + +virtual patch +virtual org +virtual report +virtual context + +@r2 depends on patch@ +expression E; +position p; +@@ + +E = kmap(...); +- if (!E) { +- ... +- } + +@r depends on context || report || org @ +expression E; +position p; +@@ + +* E = kmap(...); +* if (@p!E) { +* ... +* } + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "WARNING: NULL check on kmap() result is not needed." +coccilib.report.print_report(p[0], msg) -- 2.9.3
[PATCH V3 linux-next] nfs: use kmap/kunmap directly
This patch removes useless nfs_readdir_get_array() and nfs_readdir_release_array() as suggested by Trond Myklebust nfs_readdir() calls nfs_revalidate_mapping() before readdir_search_pagecache() , nfs_do_filldir(), uncached_readdir() so mapping should be correct. While kmap() can't fail, all subsequent error checks were removed as well as unused labels. Signed-off-by: Fabian Frederick <f...@skynet.be> --- V3: -Remove nfs_readdir_get_array()/release_array() (suggested by Trond Myklebust) -Remove subsequent checks V2: -Remove ptr and return kmap(page) directly (suggested by Anna Schumaker) fs/nfs/dir.c | 67 +++- 1 file changed, 12 insertions(+), 55 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..32ccd77 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -170,27 +170,6 @@ typedef struct { } nfs_readdir_descriptor_t; /* - * The caller is responsible for calling nfs_readdir_release_array(page) - */ -static -struct nfs_cache_array *nfs_readdir_get_array(struct page *page) -{ - void *ptr; - if (page == NULL) - return ERR_PTR(-EIO); - ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); - return ptr; -} - -static -void nfs_readdir_release_array(struct page *page) -{ - kunmap(page); -} - -/* * we are freeing strings created by nfs_add_to_readdir_array() */ static @@ -229,13 +208,10 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le static int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) { - struct nfs_cache_array *array = nfs_readdir_get_array(page); + struct nfs_cache_array *array = kmap(page); struct nfs_cache_array_entry *cache_entry; int ret; - if (IS_ERR(array)) - return PTR_ERR(array); - cache_entry = >array[array->size]; /* Check that this entry lies within the page bounds */ @@ -254,7 +230,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) if (entry->eof != 0) array->eof_index = array->size; out: - nfs_readdir_release_array(page); + kunmap(page); return ret; } @@ -343,11 +319,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array; int status; - array = nfs_readdir_get_array(desc->page); - if (IS_ERR(array)) { - status = PTR_ERR(array); - goto out; - } + array = kmap(desc->page); if (*desc->dir_cookie == 0) status = nfs_readdir_search_for_pos(array, desc); @@ -359,8 +331,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) desc->current_index += array->size; desc->page_index++; } - nfs_readdir_release_array(desc->page); -out: + kunmap(desc->page); return status; } @@ -596,13 +567,10 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en out_nopages: if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) { - array = nfs_readdir_get_array(page); - if (!IS_ERR(array)) { - array->eof_index = array->size; - status = 0; - nfs_readdir_release_array(page); - } else - status = PTR_ERR(array); + array = kmap(page); + array->eof_index = array->size; + status = 0; + kunmap(page); } put_page(scratch); @@ -664,11 +632,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, goto out; } - array = nfs_readdir_get_array(page); - if (IS_ERR(array)) { - status = PTR_ERR(array); - goto out_label_free; - } + array = kmap(page); memset(array, 0, sizeof(struct nfs_cache_array)); array->eof_index = -1; @@ -692,8 +656,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, nfs_readdir_free_pages(pages, array_size); out_release_array: - nfs_readdir_release_array(page); -out_label_free: + kunmap(page); nfs4_label_free(entry.label); out: nfs_free_fattr(entry.fattr); @@ -791,12 +754,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array = NULL; struct nfs_open_dir_context *ctx = file->private_data; - array = nfs_readdir_get_array(desc->page); - if (IS_ERR(array)) { - res = PTR_ERR(array); - goto out; - } - + array = kmap(desc->page); for (i = desc->cache_entry_index; i < array->size; i++) {
[PATCH V3 linux-next] nfs: use kmap/kunmap directly
This patch removes useless nfs_readdir_get_array() and nfs_readdir_release_array() as suggested by Trond Myklebust nfs_readdir() calls nfs_revalidate_mapping() before readdir_search_pagecache() , nfs_do_filldir(), uncached_readdir() so mapping should be correct. While kmap() can't fail, all subsequent error checks were removed as well as unused labels. Signed-off-by: Fabian Frederick --- V3: -Remove nfs_readdir_get_array()/release_array() (suggested by Trond Myklebust) -Remove subsequent checks V2: -Remove ptr and return kmap(page) directly (suggested by Anna Schumaker) fs/nfs/dir.c | 67 +++- 1 file changed, 12 insertions(+), 55 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..32ccd77 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -170,27 +170,6 @@ typedef struct { } nfs_readdir_descriptor_t; /* - * The caller is responsible for calling nfs_readdir_release_array(page) - */ -static -struct nfs_cache_array *nfs_readdir_get_array(struct page *page) -{ - void *ptr; - if (page == NULL) - return ERR_PTR(-EIO); - ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); - return ptr; -} - -static -void nfs_readdir_release_array(struct page *page) -{ - kunmap(page); -} - -/* * we are freeing strings created by nfs_add_to_readdir_array() */ static @@ -229,13 +208,10 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le static int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) { - struct nfs_cache_array *array = nfs_readdir_get_array(page); + struct nfs_cache_array *array = kmap(page); struct nfs_cache_array_entry *cache_entry; int ret; - if (IS_ERR(array)) - return PTR_ERR(array); - cache_entry = >array[array->size]; /* Check that this entry lies within the page bounds */ @@ -254,7 +230,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) if (entry->eof != 0) array->eof_index = array->size; out: - nfs_readdir_release_array(page); + kunmap(page); return ret; } @@ -343,11 +319,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array; int status; - array = nfs_readdir_get_array(desc->page); - if (IS_ERR(array)) { - status = PTR_ERR(array); - goto out; - } + array = kmap(desc->page); if (*desc->dir_cookie == 0) status = nfs_readdir_search_for_pos(array, desc); @@ -359,8 +331,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) desc->current_index += array->size; desc->page_index++; } - nfs_readdir_release_array(desc->page); -out: + kunmap(desc->page); return status; } @@ -596,13 +567,10 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en out_nopages: if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) { - array = nfs_readdir_get_array(page); - if (!IS_ERR(array)) { - array->eof_index = array->size; - status = 0; - nfs_readdir_release_array(page); - } else - status = PTR_ERR(array); + array = kmap(page); + array->eof_index = array->size; + status = 0; + kunmap(page); } put_page(scratch); @@ -664,11 +632,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, goto out; } - array = nfs_readdir_get_array(page); - if (IS_ERR(array)) { - status = PTR_ERR(array); - goto out_label_free; - } + array = kmap(page); memset(array, 0, sizeof(struct nfs_cache_array)); array->eof_index = -1; @@ -692,8 +656,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, nfs_readdir_free_pages(pages, array_size); out_release_array: - nfs_readdir_release_array(page); -out_label_free: + kunmap(page); nfs4_label_free(entry.label); out: nfs_free_fattr(entry.fattr); @@ -791,12 +754,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) struct nfs_cache_array *array = NULL; struct nfs_open_dir_context *ctx = file->private_data; - array = nfs_readdir_get_array(desc->page); - if (IS_ERR(array)) { - res = PTR_ERR(array); - goto out; - } - + array = kmap(desc->page); for (i = desc->cache_entry_index; i < array->size; i++) { struct nfs_cache_
[PATCH 2/2 linux-next] gfs2: remove unused flags parameter
We already assumed rename flags when calling gfs2_exchange() Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/gfs2/inode.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9698796..b5858a3 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1567,14 +1567,12 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, * @odentry: The old dentry of the file * @ndir: Parent directory of new file name * @ndentry: The new dentry of the file - * @flags: The rename flags * * Returns: errno */ static int gfs2_exchange(struct inode *odir, struct dentry *odentry, -struct inode *ndir, struct dentry *ndentry, -unsigned int flags) +struct inode *ndir, struct dentry *ndentry) { struct gfs2_inode *odip = GFS2_I(odir); struct gfs2_inode *ndip = GFS2_I(ndir); @@ -1710,7 +1708,7 @@ static int gfs2_rename2(struct inode *odir, struct dentry *odentry, return -EINVAL; if (flags & RENAME_EXCHANGE) - return gfs2_exchange(odir, odentry, ndir, ndentry, flags); + return gfs2_exchange(odir, odentry, ndir, ndentry); return gfs2_rename(odir, odentry, ndir, ndentry); } -- 2.9.3
[PATCH 2/2 linux-next] gfs2: remove unused flags parameter
We already assumed rename flags when calling gfs2_exchange() Signed-off-by: Fabian Frederick --- fs/gfs2/inode.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9698796..b5858a3 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1567,14 +1567,12 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, * @odentry: The old dentry of the file * @ndir: Parent directory of new file name * @ndentry: The new dentry of the file - * @flags: The rename flags * * Returns: errno */ static int gfs2_exchange(struct inode *odir, struct dentry *odentry, -struct inode *ndir, struct dentry *ndentry, -unsigned int flags) +struct inode *ndir, struct dentry *ndentry) { struct gfs2_inode *odip = GFS2_I(odir); struct gfs2_inode *ndip = GFS2_I(ndir); @@ -1710,7 +1708,7 @@ static int gfs2_rename2(struct inode *odir, struct dentry *odentry, return -EINVAL; if (flags & RENAME_EXCHANGE) - return gfs2_exchange(odir, odentry, ndir, ndentry, flags); + return gfs2_exchange(odir, odentry, ndir, ndentry); return gfs2_rename(odir, odentry, ndir, ndentry); } -- 2.9.3
[PATCH 1/2 linux-next] gfs2: check rename2 flags at once
There's no need to update flags in gfs2_rename2() This will ease whiteout addition. Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/gfs2/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9f605ea..9698796 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1706,9 +1706,7 @@ static int gfs2_rename2(struct inode *odir, struct dentry *odentry, struct inode *ndir, struct dentry *ndentry, unsigned int flags) { - flags &= ~RENAME_NOREPLACE; - - if (flags & ~RENAME_EXCHANGE) + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) return -EINVAL; if (flags & RENAME_EXCHANGE) -- 2.9.3
[PATCH 1/2 linux-next] gfs2: check rename2 flags at once
There's no need to update flags in gfs2_rename2() This will ease whiteout addition. Signed-off-by: Fabian Frederick --- fs/gfs2/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 9f605ea..9698796 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1706,9 +1706,7 @@ static int gfs2_rename2(struct inode *odir, struct dentry *odentry, struct inode *ndir, struct dentry *ndentry, unsigned int flags) { - flags &= ~RENAME_NOREPLACE; - - if (flags & ~RENAME_EXCHANGE) + if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) return -EINVAL; if (flags & RENAME_EXCHANGE) -- 2.9.3
[PATCH V2 linux-next] nfs: kmap can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick <f...@skynet.be> --- V2: Remove ptr and return kmap(page) directly (Suggested by Anna Schumaker) fs/nfs/dir.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..12ed806b 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -175,13 +175,9 @@ typedef struct { static struct nfs_cache_array *nfs_readdir_get_array(struct page *page) { - void *ptr; if (page == NULL) return ERR_PTR(-EIO); - ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); - return ptr; + return kmap(page); } static -- 2.9.3
[PATCH V2 linux-next] nfs: kmap can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick --- V2: Remove ptr and return kmap(page) directly (Suggested by Anna Schumaker) fs/nfs/dir.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..12ed806b 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -175,13 +175,9 @@ typedef struct { static struct nfs_cache_array *nfs_readdir_get_array(struct page *page) { - void *ptr; if (page == NULL) return ERR_PTR(-EIO); - ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); - return ptr; + return kmap(page); } static -- 2.9.3
[PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail
There's no need to check kmap() return value because it won't fail. If it's highmem mapping, it will receive virtual address or a new one; if it's lowmem, all kernel pages are already being mapped. (Thanks to Jan Kara for explanations) Signed-off-by: Fabian Frederick <f...@skynet.be> --- V2: Verbose description (suggested by Greg Kroah-Hartman) drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 151abf0..7d2f8d9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -328,15 +328,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - src = (char *)kmap(bo->page_obj[idx].page); - if (!src) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - - src += offset; + src = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; @@ -533,14 +525,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - des = (char *)kmap(bo->page_obj[idx].page); - if (!des) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - des += offset; + des = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; -- 2.9.3
[PATCH V2 linux-next] staging: media: atomisp: kmap() can't fail
There's no need to check kmap() return value because it won't fail. If it's highmem mapping, it will receive virtual address or a new one; if it's lowmem, all kernel pages are already being mapped. (Thanks to Jan Kara for explanations) Signed-off-by: Fabian Frederick --- V2: Verbose description (suggested by Greg Kroah-Hartman) drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 151abf0..7d2f8d9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -328,15 +328,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - src = (char *)kmap(bo->page_obj[idx].page); - if (!src) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - - src += offset; + src = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; @@ -533,14 +525,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - des = (char *)kmap(bo->page_obj[idx].page); - if (!des) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - des += offset; + des = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; -- 2.9.3
[PATCH 1/1 linux-next] btrfs: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/btrfs/check-integrity.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index ab14c2e..496eb00 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -1668,14 +1668,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, dev_bytenr += (j - i) * PAGE_SIZE; i = j; } - for (i = 0; i < num_pages; i++) { + for (i = 0; i < num_pages; i++) block_ctx->datav[i] = kmap(block_ctx->pagev[i]); - if (!block_ctx->datav[i]) { - pr_info("btrfsic: kmap() failed (dev %s)!\n", - block_ctx->dev->name); - return -1; - } - } return block_ctx->len; } -- 2.9.3
[PATCH 1/1 linux-next] btrfs: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick --- fs/btrfs/check-integrity.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index ab14c2e..496eb00 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -1668,14 +1668,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, dev_bytenr += (j - i) * PAGE_SIZE; i = j; } - for (i = 0; i < num_pages; i++) { + for (i = 0; i < num_pages; i++) block_ctx->datav[i] = kmap(block_ctx->pagev[i]); - if (!block_ctx->datav[i]) { - pr_info("btrfsic: kmap() failed (dev %s)!\n", - block_ctx->dev->name); - return -1; - } - } return block_ctx->len; } -- 2.9.3
[PATCH 1/1 linux-next] nfs: kmap can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/nfs/dir.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..f89e54c 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -179,8 +179,6 @@ struct nfs_cache_array *nfs_readdir_get_array(struct page *page) if (page == NULL) return ERR_PTR(-EIO); ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); return ptr; } -- 2.9.3
[PATCH 1/1 linux-next] nfs: kmap can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick --- fs/nfs/dir.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3a188cb..f89e54c 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -179,8 +179,6 @@ struct nfs_cache_array *nfs_readdir_get_array(struct page *page) if (page == NULL) return ERR_PTR(-EIO); ptr = kmap(page); - if (ptr == NULL) - return ERR_PTR(-ENOMEM); return ptr; } -- 2.9.3
[PATCH 1/1 linux-next] scripts/coccinelle/misc: Warn about NULL check on kmap()
This script removes NULL check on kmap() and all process involved (OOM message ...) Thanks to Jan Kara for explanations. Signed-off-by: Fabian Frederick <f...@skynet.be> --- scripts/coccinelle/misc/kmap.cocci | 43 ++ 1 file changed, 43 insertions(+) create mode 100644 scripts/coccinelle/misc/kmap.cocci diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci new file mode 100644 index 000..9ae4a6e --- /dev/null +++ b/scripts/coccinelle/misc/kmap.cocci @@ -0,0 +1,43 @@ +/// kmap never fails; remove NULL test case. +/// +// Copyright: (C) 2017 Fabian Frederick. GPLv2. +// Comments: - +// Options: --no-includes --include-headers + +virtual patch +virtual org +virtual report +virtual context + +@r2 depends on patch@ +expression E; +position p; +@@ + +E = kmap(...); +- if (!E) { +- ... +- } + +@r depends on context || report || org @ +expression E; +position p; +@@ + +* E = kmap(...); +* if (@p!E) { +* ... +* } + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "WARNING: NULL check on kmap() result is not needed." +coccilib.report.print_report(p[0], msg) -- 2.9.3
[PATCH 1/1 linux-next] scripts/coccinelle/misc: Warn about NULL check on kmap()
This script removes NULL check on kmap() and all process involved (OOM message ...) Thanks to Jan Kara for explanations. Signed-off-by: Fabian Frederick --- scripts/coccinelle/misc/kmap.cocci | 43 ++ 1 file changed, 43 insertions(+) create mode 100644 scripts/coccinelle/misc/kmap.cocci diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci new file mode 100644 index 000..9ae4a6e --- /dev/null +++ b/scripts/coccinelle/misc/kmap.cocci @@ -0,0 +1,43 @@ +/// kmap never fails; remove NULL test case. +/// +// Copyright: (C) 2017 Fabian Frederick. GPLv2. +// Comments: - +// Options: --no-includes --include-headers + +virtual patch +virtual org +virtual report +virtual context + +@r2 depends on patch@ +expression E; +position p; +@@ + +E = kmap(...); +- if (!E) { +- ... +- } + +@r depends on context || report || org @ +expression E; +position p; +@@ + +* E = kmap(...); +* if (@p!E) { +* ... +* } + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "WARNING: NULL check on kmap() result is not needed." +coccilib.report.print_report(p[0], msg) -- 2.9.3
[PATCH 1/1 linux-next] efi/capsule: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick <f...@skynet.be> --- drivers/firmware/efi/capsule-loader.c | 5 - drivers/firmware/efi/capsule.c| 4 2 files changed, 9 deletions(-) diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 9ae6c11..bf8b2ef 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -183,11 +183,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, page = cap_info->pages[cap_info->index - 1]; kbuff = kmap(page); - if (!kbuff) { - pr_debug("%s: kmap() failed\n", __func__); - ret = -EFAULT; - goto failed; - } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; /* Copy capsule binary data from user space to kernel space buffer */ diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 6eedff4..e603ccf 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -247,10 +247,6 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages) efi_capsule_block_desc_t *sglist; sglist = kmap(sg_pages[i]); - if (!sglist) { - rv = -ENOMEM; - goto out; - } for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, PAGE_SIZE); -- 2.9.3
[PATCH 1/1 linux-next] efi/capsule: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick --- drivers/firmware/efi/capsule-loader.c | 5 - drivers/firmware/efi/capsule.c| 4 2 files changed, 9 deletions(-) diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c index 9ae6c11..bf8b2ef 100644 --- a/drivers/firmware/efi/capsule-loader.c +++ b/drivers/firmware/efi/capsule-loader.c @@ -183,11 +183,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff, page = cap_info->pages[cap_info->index - 1]; kbuff = kmap(page); - if (!kbuff) { - pr_debug("%s: kmap() failed\n", __func__); - ret = -EFAULT; - goto failed; - } kbuff += PAGE_SIZE - cap_info->page_bytes_remain; /* Copy capsule binary data from user space to kernel space buffer */ diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 6eedff4..e603ccf 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -247,10 +247,6 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages) efi_capsule_block_desc_t *sglist; sglist = kmap(sg_pages[i]); - if (!sglist) { - rv = -ENOMEM; - goto out; - } for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, PAGE_SIZE); -- 2.9.3
[PATCH 1/1 linux-next] staging: media: atomisp: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick <f...@skynet.be> --- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 151abf0..7d2f8d9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -328,15 +328,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - src = (char *)kmap(bo->page_obj[idx].page); - if (!src) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - - src += offset; + src = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; @@ -533,14 +525,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - des = (char *)kmap(bo->page_obj[idx].page); - if (!des) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - des += offset; + des = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; -- 2.9.3
[PATCH 1/1 linux-next] staging: media: atomisp: kmap() can't fail
Remove NULL test on kmap() Signed-off-by: Fabian Frederick --- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 151abf0..7d2f8d9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -328,15 +328,7 @@ static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int byte idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - src = (char *)kmap(bo->page_obj[idx].page); - if (!src) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - - src += offset; + src = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; @@ -533,14 +525,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes) idx = (virt - bo->start) >> PAGE_SHIFT; offset = (virt - bo->start) - (idx << PAGE_SHIFT); - des = (char *)kmap(bo->page_obj[idx].page); - if (!des) { - dev_err(atomisp_dev, - "kmap buffer object page failed: " - "pg_idx = %d\n", idx); - return -EINVAL; - } - des += offset; + des = (char *)kmap(bo->page_obj[idx].page) + offset; if ((bytes + offset) >= PAGE_SIZE) { len = PAGE_SIZE - offset; -- 2.9.3
[PATCH 2/2 linux-next] fs/affs: bugfix: Write files greater than page size on OFS
Previous AFFS patch fixed OFS write operations but unveiled another bug: files greater than 4KB are being created with a wrong size resulting in errors like the following: dd if=/dev/zero of=file bs=4097 count=1 cp file /mnt/affs/ cp: error writing '/mnt/affs/file': Bad address Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/affs/file.c b/fs/affs/file.c index e5c5de6..196ee7f 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -679,7 +679,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, int written; from = pos & (PAGE_SIZE - 1); - to = pos + len; + to = from + len; /* * XXX: not sure if this can handle short copies (len < copied), but * we don't have to, because the page should always be uptodate here, -- 2.9.3
[PATCH 2/2 linux-next] fs/affs: bugfix: Write files greater than page size on OFS
Previous AFFS patch fixed OFS write operations but unveiled another bug: files greater than 4KB are being created with a wrong size resulting in errors like the following: dd if=/dev/zero of=file bs=4097 count=1 cp file /mnt/affs/ cp: error writing '/mnt/affs/file': Bad address Signed-off-by: Fabian Frederick --- fs/affs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/affs/file.c b/fs/affs/file.c index e5c5de6..196ee7f 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -679,7 +679,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, int written; from = pos & (PAGE_SIZE - 1); - to = pos + len; + to = from + len; /* * XXX: not sure if this can handle short copies (len < copied), but * we don't have to, because the page should always be uptodate here, -- 2.9.3
[PATCH 1/2 linux-next] fs/affs: bugfix: enable writes on OFS disks
We called unconditionally affs_bread_ino() with create 0 resulting in "error (device ...): get_block(): strange block request 0" when trying to write on AFFS OFS format. This patch adds create parameter to that function. 0 for affs_readpage_ofs() 1 for affs_write_begin_ofs() Bug was found here: https://bugzilla.kernel.org/show_bug.cgi?id=114961 Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/affs/file.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/affs/file.c b/fs/affs/file.c index 0deec9c..e5c5de6 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -499,7 +499,7 @@ affs_getemptyblk_ino(struct inode *inode, int block) } static int -affs_do_readpage_ofs(struct page *page, unsigned to) +affs_do_readpage_ofs(struct page *page, unsigned to, int create) { struct inode *inode = page->mapping->host; struct super_block *sb = inode->i_sb; @@ -518,7 +518,7 @@ affs_do_readpage_ofs(struct page *page, unsigned to) boff = tmp % bsize; while (pos < to) { - bh = affs_bread_ino(inode, bidx, 0); + bh = affs_bread_ino(inode, bidx, create); if (IS_ERR(bh)) return PTR_ERR(bh); tmp = min(bsize - boff, to - pos); @@ -620,7 +620,7 @@ affs_readpage_ofs(struct file *file, struct page *page) memset(page_address(page) + to, 0, PAGE_SIZE - to); } - err = affs_do_readpage_ofs(page, to); + err = affs_do_readpage_ofs(page, to, 0); if (!err) SetPageUptodate(page); unlock_page(page); @@ -657,7 +657,7 @@ static int affs_write_begin_ofs(struct file *file, struct address_space *mapping return 0; /* XXX: inefficient but safe in the face of short writes */ - err = affs_do_readpage_ofs(page, PAGE_SIZE); + err = affs_do_readpage_ofs(page, PAGE_SIZE, 1); if (err) { unlock_page(page); put_page(page); -- 2.9.3