aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e53835b88594..5f01dad4b696 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1543,7 +1543,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
1543 btrfs_set_device_io_align(leaf, dev_item, device->io_align); 1543 btrfs_set_device_io_align(leaf, dev_item, device->io_align);
1544 btrfs_set_device_io_width(leaf, dev_item, device->io_width); 1544 btrfs_set_device_io_width(leaf, dev_item, device->io_width);
1545 btrfs_set_device_sector_size(leaf, dev_item, device->sector_size); 1545 btrfs_set_device_sector_size(leaf, dev_item, device->sector_size);
1546 btrfs_set_device_total_bytes(leaf, dev_item, device->total_bytes); 1546 btrfs_set_device_total_bytes(leaf, dev_item, device->disk_total_bytes);
1547 btrfs_set_device_bytes_used(leaf, dev_item, device->bytes_used); 1547 btrfs_set_device_bytes_used(leaf, dev_item, device->bytes_used);
1548 btrfs_mark_buffer_dirty(leaf); 1548 btrfs_mark_buffer_dirty(leaf);
1549 1549
@@ -1940,14 +1940,6 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
1940 device->total_bytes = new_size; 1940 device->total_bytes = new_size;
1941 if (device->writeable) 1941 if (device->writeable)
1942 device->fs_devices->total_rw_bytes -= diff; 1942 device->fs_devices->total_rw_bytes -= diff;
1943 ret = btrfs_update_device(trans, device);
1944 if (ret) {
1945 unlock_chunks(root);
1946 btrfs_end_transaction(trans, root);
1947 goto done;
1948 }
1949 WARN_ON(diff > old_total);
1950 btrfs_set_super_total_bytes(super_copy, old_total - diff);
1951 unlock_chunks(root); 1943 unlock_chunks(root);
1952 btrfs_end_transaction(trans, root); 1944 btrfs_end_transaction(trans, root);
1953 1945
@@ -1979,7 +1971,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
1979 length = btrfs_dev_extent_length(l, dev_extent); 1971 length = btrfs_dev_extent_length(l, dev_extent);
1980 1972
1981 if (key.offset + length <= new_size) 1973 if (key.offset + length <= new_size)
1982 goto done; 1974 break;
1983 1975
1984 chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent); 1976 chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent);
1985 chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent); 1977 chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent);
@@ -1992,6 +1984,26 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
1992 goto done; 1984 goto done;
1993 } 1985 }
1994 1986
1987 /* Shrinking succeeded, else we would be at "done". */
1988 trans = btrfs_start_transaction(root, 1);
1989 if (!trans) {
1990 ret = -ENOMEM;
1991 goto done;
1992 }
1993 lock_chunks(root);
1994
1995 device->disk_total_bytes = new_size;
1996 /* Now btrfs_update_device() will change the on-disk size. */
1997 ret = btrfs_update_device(trans, device);
1998 if (ret) {
1999 unlock_chunks(root);
2000 btrfs_end_transaction(trans, root);
2001 goto done;
2002 }
2003 WARN_ON(diff > old_total);
2004 btrfs_set_super_total_bytes(super_copy, old_total - diff);
2005 unlock_chunks(root);
2006 btrfs_end_transaction(trans, root);
1995done: 2007done:
1996 btrfs_free_path(path); 2008 btrfs_free_path(path);
1997 return ret; 2009 return ret;
@@ -3076,7 +3088,8 @@ static int fill_device_from_item(struct extent_buffer *leaf,
3076 unsigned long ptr; 3088 unsigned long ptr;
3077 3089
3078 device->devid = btrfs_device_id(leaf, dev_item); 3090 device->devid = btrfs_device_id(leaf, dev_item);
3079 device->total_bytes = btrfs_device_total_bytes(leaf, dev_item); 3091 device->disk_total_bytes = btrfs_device_total_bytes(leaf, dev_item);
3092 device->total_bytes = device->disk_total_bytes;
3080 device->bytes_used = btrfs_device_bytes_used(leaf, dev_item); 3093 device->bytes_used = btrfs_device_bytes_used(leaf, dev_item);
3081 device->type = btrfs_device_type(leaf, dev_item); 3094 device->type = btrfs_device_type(leaf, dev_item);
3082 device->io_align = btrfs_device_io_align(leaf, dev_item); 3095 device->io_align = btrfs_device_io_align(leaf, dev_item);
_bond_info ad_info; struct alb_bond_info alb_info; struct bond_params params; struct list_head vlan_list; struct vlan_group *vlgrp; struct packet_type arp_mon_pt; struct workqueue_struct *wq; struct delayed_work mii_work; struct delayed_work arp_work; struct delayed_work alb_work; struct delayed_work ad_work; struct delayed_work mcast_work; #ifdef CONFIG_DEBUG_FS /* debugging suport via debugfs */ struct dentry *debug_dir; #endif /* CONFIG_DEBUG_FS */ }; #define bond_slave_get_rcu(dev) \ ((struct slave *) rcu_dereference(dev->rx_handler_data)) /** * Returns NULL if the net_device does not belong to any of the bond's slaves * * Caller must hold bond lock for read */ static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, struct net_device *slave_dev) { struct slave *slave = NULL; int i; bond_for_each_slave(bond, slave, i) { if (slave->dev == slave_dev) { return slave; } } return NULL; } static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) { if (!slave || !slave->dev->master) { return NULL; } return netdev_priv(slave->dev->master); } static inline bool bond_is_lb(const struct bonding *bond) { return (bond->params.mode == BOND_MODE_TLB || bond->params.mode == BOND_MODE_ALB); } static inline void bond_set_active_slave(struct slave *slave) { slave->backup = 0; } static inline void bond_set_backup_slave(struct slave *slave) { slave->backup = 1; } static inline int bond_slave_state(struct slave *slave) { return slave->backup; } static inline bool bond_is_active_slave(struct slave *slave) { return !bond_slave_state(slave); } #define BOND_PRI_RESELECT_ALWAYS 0 #define BOND_PRI_RESELECT_BETTER 1 #define BOND_PRI_RESELECT_FAILURE 2 #define BOND_FOM_NONE 0 #define BOND_FOM_ACTIVE 1 #define BOND_FOM_FOLLOW 2 #define BOND_ARP_VALIDATE_NONE 0 #define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE) #define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP) #define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \ BOND_ARP_VALIDATE_BACKUP) static inline int slave_do_arp_validate(struct bonding *bond, struct slave *slave) { return bond->params.arp_validate & (1 << bond_slave_state(slave)); } static inline unsigned long slave_last_rx(struct bonding *bond, struct slave *slave) { if (slave_do_arp_validate(bond, slave)) return slave->last_arp_rx; return slave->dev->last_rx; } #ifdef CONFIG_NET_POLL_CONTROLLER static inline void bond_netpoll_send_skb(const struct slave *slave, struct sk_buff *skb) { struct netpoll *np = slave->np; if (np) netpoll_send_skb(np, skb); } #else static inline void bond_netpoll_send_skb(const struct slave *slave, struct sk_buff *skb) { } #endif static inline void bond_set_slave_inactive_flags(struct slave *slave) { struct bonding *bond = netdev_priv(slave->dev->master); if (!bond_is_lb(bond)) bond_set_backup_slave(slave); if (!bond->params.all_slaves_active) slave->inactive = 1; } static inline void bond_set_slave_active_flags(struct slave *slave) { bond_set_active_slave(slave); slave->inactive = 0; } static inline bool bond_is_slave_inactive(struct slave *slave) { return slave->inactive; } struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); int bond_create(struct net *net, const char *name); int bond_create_sysfs(void); void bond_destroy_sysfs(void); void bond_prepare_sysfs_group(struct bonding *bond); int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); void bond_mii_monitor(struct work_struct *); void bond_loadbalance_arp_mon(struct work_struct *); void bond_activebackup_arp_mon(struct work_struct *); void bond_set_mode_ops(struct bonding *bond, int mode); int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl); void bond_select_active_slave(struct bonding *bond); void bond_change_active_slave(struct bonding *bond, struct slave *new_active); void bond_create_debugfs(void); void bond_destroy_debugfs(void); void bond_debug_register(struct bonding *bond); void bond_debug_unregister(struct bonding *bond); void bond_debug_reregister(struct bonding *bond); const char *bond_mode_name(int mode); struct bond_net { struct net * net; /* Associated network namespace */ struct list_head dev_list; #ifdef CONFIG_PROC_FS struct proc_dir_entry * proc_dir; #endif }; #ifdef CONFIG_PROC_FS void bond_create_proc_entry(struct bonding *bond); void bond_remove_proc_entry(struct bonding *bond); void bond_create_proc_dir(struct bond_net *bn); void bond_destroy_proc_dir(struct bond_net *bn); #else static inline void bond_create_proc_entry(struct bonding *bond) { } static inline void bond_remove_proc_entry(struct bonding *bond) { } static inline void bond_create_proc_dir(struct bond_net *bn) { } static inline void bond_destroy_proc_dir(struct bond_net *bn) { } #endif /* exported from bond_main.c */ extern int bond_net_id; extern const struct bond_parm_tbl bond_lacp_tbl[]; extern const struct bond_parm_tbl bond_mode_tbl[]; extern const struct bond_parm_tbl xmit_hashtype_tbl[]; extern const struct bond_parm_tbl arp_validate_tbl[]; extern const struct bond_parm_tbl fail_over_mac_tbl[]; extern const struct bond_parm_tbl pri_reselect_tbl[]; extern struct bond_parm_tbl ad_select_tbl[]; #endif /* _LINUX_BONDING_H */