aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
authorMingming <cmm@us.ibm.com>2008-05-27 10:55:43 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commite1b81e6761bd8419146d4bbe0aadd8b2d348a01c (patch)
treea21c101b1dddf5acfd26dc8cd09570acb193b25e /fs/btrfs/ordered-data.c
parentda496f2acf61153e0d4d42ded6a53f3367939db0 (diff)
btrfs delete ordered inode handling fix
Use btrfs_release_file instead of a put_inode call Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 3814cb0246b4..8dd8180183ff 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -231,7 +231,7 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
231 return 1; 231 return 1;
232} 232}
233 233
234static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree, 234static void __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree,
235 struct inode *inode, 235 struct inode *inode,
236 u64 root_objectid, u64 objectid) 236 u64 root_objectid, u64 objectid)
237{ 237{
@@ -243,31 +243,38 @@ static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree,
243 node = __tree_search(&tree->tree, root_objectid, objectid, &prev); 243 node = __tree_search(&tree->tree, root_objectid, objectid, &prev);
244 if (!node) { 244 if (!node) {
245 write_unlock(&tree->lock); 245 write_unlock(&tree->lock);
246 return 0; 246 return;
247 } 247 }
248 rb_erase(node, &tree->tree); 248 rb_erase(node, &tree->tree);
249 BTRFS_I(inode)->ordered_trans = 0; 249 BTRFS_I(inode)->ordered_trans = 0;
250 write_unlock(&tree->lock); 250 write_unlock(&tree->lock);
251 atomic_dec(&inode->i_count);
251 entry = rb_entry(node, struct tree_entry, rb_node); 252 entry = rb_entry(node, struct tree_entry, rb_node);
252 kfree(entry); 253 kfree(entry);
253 return 1; 254 return;
254} 255}
255 256
256int btrfs_del_ordered_inode(struct inode *inode) 257void btrfs_del_ordered_inode(struct inode *inode)
257{ 258{
258 struct btrfs_root *root = BTRFS_I(inode)->root; 259 struct btrfs_root *root = BTRFS_I(inode)->root;
259 u64 root_objectid = root->root_key.objectid; 260 u64 root_objectid = root->root_key.objectid;
260 int ret = 0; 261
262 if (!BTRFS_I(inode)->ordered_trans) {
263 return;
264 }
265
266 if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) ||
267 mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))
268 return;
261 269
262 spin_lock(&root->fs_info->new_trans_lock); 270 spin_lock(&root->fs_info->new_trans_lock);
263 if (root->fs_info->running_transaction) { 271 if (root->fs_info->running_transaction) {
264 struct btrfs_ordered_inode_tree *tree; 272 struct btrfs_ordered_inode_tree *tree;
265 tree = &root->fs_info->running_transaction->ordered_inode_tree; 273 tree = &root->fs_info->running_transaction->ordered_inode_tree;
266 ret = __btrfs_del_ordered_inode(tree, inode, root_objectid, 274 __btrfs_del_ordered_inode(tree, inode, root_objectid,
267 inode->i_ino); 275 inode->i_ino);
268 } 276 }
269 spin_unlock(&root->fs_info->new_trans_lock); 277 spin_unlock(&root->fs_info->new_trans_lock);
270 return ret;
271} 278}
272 279
273int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode) 280int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode)
>128 129 130 131 132 133 134 135 136 137 138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217



















                                                                              
                        





















                                                                                                      
                                                                                 

                                                                                                                      
                                                                                              















                                                                                             
                                                                              












                                                                            
                                                                                         







                                                                      
                                                      
 
                                                                                                  
                                                                              


                                                                         















                                                                      
  
                                                             












                                                                     
                                                              












                                                         
                                                                       


                                                       
                                                           

 

                                                                        
                                      

 

                                                          
                                        






















                                                        
                  





























                                    
                            
                                    
                            
                            
                            
                            
                            
                                    

      
#ifndef _SERIO_H
#define _SERIO_H

/*
 * Copyright (C) 1999-2002 Vojtech Pavlik
*
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 */

#include <linux/ioctl.h>

#define SPIOCSTYPE	_IOW('q', 0x01, unsigned long)

#ifdef __KERNEL__

#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <linux/mod_devicetable.h>

struct serio {
	void *port_data;

	char name[32];
	char phys[32];

	unsigned int manual_bind;

	struct serio_device_id id;

	spinlock_t lock;		/* protects critical sections from port's interrupt handler */

	int (*write)(struct serio *, unsigned char);
	int (*open)(struct serio *);
	void (*close)(struct serio *);
	int (*start)(struct serio *);
	void (*stop)(struct serio *);

	struct serio *parent, *child;
	unsigned int depth;		/* level of nesting in serio hierarchy */

	struct serio_driver *drv;	/* accessed from interrupt, must be protected by serio->lock and serio->sem */
	struct mutex drv_mutex;		/* protects serio->drv so attributes can pin driver */

	struct device dev;
	unsigned int registered;	/* port has been fully registered with driver core */

	struct list_head node;
};
#define to_serio_port(d)	container_of(d, struct serio, dev)

struct serio_driver {
	void *private;
	char *description;

	struct serio_device_id *id_table;
	unsigned int manual_bind;

	void (*write_wakeup)(struct serio *);
	irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
	int  (*connect)(struct serio *, struct serio_driver *drv);
	int  (*reconnect)(struct serio *);
	void (*disconnect)(struct serio *);
	void (*cleanup)(struct serio *);

	struct device_driver driver;
};
#define to_serio_driver(d)	container_of(d, struct serio_driver, driver)

int serio_open(struct serio *serio, struct serio_driver *drv);
void serio_close(struct serio *serio);
void serio_rescan(struct serio *serio);
void serio_reconnect(struct serio *serio);
irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags);

void __serio_register_port(struct serio *serio, struct module *owner);
static inline void serio_register_port(struct serio *serio)
{
	__serio_register_port(serio, THIS_MODULE);
}

void serio_unregister_port(struct serio *serio);
void serio_unregister_child_port(struct serio *serio);

int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name);
static inline int __must_check serio_register_driver(struct serio_driver *drv)
{
	return __serio_register_driver(drv, THIS_MODULE, KBUILD_MODNAME);
}
void serio_unregister_driver(struct serio_driver *drv);

static inline int serio_write(struct serio *serio, unsigned char data)
{
	if (serio->write)
		return serio->write(serio, data);
	else
		return -1;
}

static inline void serio_drv_write_wakeup(struct serio *serio)
{
	if (serio->drv && serio->drv->write_wakeup)
		serio->drv->write_wakeup(serio);
}

/*
 * Use the following functions to manipulate serio's per-port
 * driver-specific data.
 */
static inline void *serio_get_drvdata(struct serio *serio)
{
	return dev_get_drvdata(&serio->dev);
}

static inline void serio_set_drvdata(struct serio *serio, void *data)
{
	dev_set_drvdata(&serio->dev, data);
}

/*
 * Use the following functions to protect critical sections in
 * driver code from port's interrupt handler
 */
static inline void serio_pause_rx(struct serio *serio)
{
	spin_lock_irq(&serio->lock);
}

static inline void serio_continue_rx(struct serio *serio)
{
	spin_unlock_irq(&serio->lock);
}

/*
 * Use the following functions to pin serio's driver in process context
 */
static inline int serio_pin_driver(struct serio *serio)
{
	return mutex_lock_interruptible(&serio->drv_mutex);
}

static inline void serio_pin_driver_uninterruptible(struct serio *serio)
{
	mutex_lock(&serio->drv_mutex);
}

static inline void serio_unpin_driver(struct serio *serio)
{
	mutex_unlock(&serio->drv_mutex);
}


#endif

/*
 * bit masks for use in "interrupt" flags (3rd argument)
 */
#define SERIO_TIMEOUT	1
#define SERIO_PARITY	2
#define SERIO_FRAME	4

/*
 * Serio types
 */
#define SERIO_XT	0x00
#define SERIO_8042	0x01
#define SERIO_RS232	0x02
#define SERIO_HIL_MLC	0x03
#define SERIO_PS_PSTHRU	0x05
#define SERIO_8042_XL	0x06

/*
 * Serio protocols
 */
#define SERIO_UNKNOWN	0x00
#define SERIO_MSC	0x01
#define SERIO_SUN	0x02
#define SERIO_MS	0x03
#define SERIO_MP	0x04
#define SERIO_MZ	0x05
#define SERIO_MZP	0x06
#define SERIO_MZPP	0x07
#define SERIO_VSXXXAA	0x08
#define SERIO_SUNKBD	0x10
#define SERIO_WARRIOR	0x18
#define SERIO_SPACEORB	0x19
#define SERIO_MAGELLAN	0x1a
#define SERIO_SPACEBALL	0x1b
#define SERIO_GUNZE	0x1c
#define SERIO_IFORCE	0x1d
#define SERIO_STINGER	0x1e
#define SERIO_NEWTON	0x1f
#define SERIO_STOWAWAY	0x20
#define SERIO_H3600	0x21
#define SERIO_PS2SER	0x22
#define SERIO_TWIDKBD	0x23
#define SERIO_TWIDJOY	0x24
#define SERIO_HIL	0x25
#define SERIO_SNES232	0x26
#define SERIO_SEMTECH	0x27
#define SERIO_LKKBD	0x28
#define SERIO_ELO	0x29
#define SERIO_MICROTOUCH	0x30
#define SERIO_PENMOUNT	0x31
#define SERIO_TOUCHRIGHT	0x32
#define SERIO_TOUCHWIN	0x33
#define SERIO_TAOSEVM	0x34
#define SERIO_FUJITSU	0x35
#define SERIO_ZHENHUA	0x36
#define SERIO_INEXIO	0x37
#define SERIO_TOUCHIT213	0x37

#endif